944,134 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 5393
  • C# RSS
Oct 10th, 2009
0

Connection to remote SQL Database problem in app

Expand Post »
Hello guys!

I am developing simple desktop application that suppose to connect to SQL DB launched on remote server.

Everything going fine, exept that when connecting to DB I get exeption "Login failed for user 'guest'."

So, looks like i need to create some user with password and give him at least 'read rights'. How can I do it.

What I tried:

1. 'sa' name doesn't work.
2. Allow remote connection - enabled.


C# Syntax (Toggle Plain Text)
  1. SqlConnection sqlconn = new SqlConnection("Data Source=64.191.121.53,1433;Network Library=DBMSSOCN;Initial Catalog=remoteDB;User ID=guest;Password=;");
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Nfurman is offline Offline
69 posts
since Oct 2009
Oct 18th, 2009
0
Re: Connection to remote SQL Database problem in app
NFurman, Looking at your connection string I am unable to determine what credentials you are using, but the credentials in the connection string should be the SQL server credentials, not the client logon credentials.
Reputation Points: 10
Solved Threads: 3
Light Poster
sanch01r is offline Offline
30 posts
since Oct 2009
Oct 19th, 2009
0
Re: Connection to remote SQL Database problem in app
You also need to set "Integrated Security=False;" when using a username/password connection string. Here are example connection string builders:
C# Syntax (Toggle Plain Text)
  1. public static string BuildSqlNativeConnStr(string server, string database)
  2. {
  3. return string.Format("Data Source={0};Initial Catalog={1};Integrated Security=True;", server, database);
  4. }
  5. public static string BuildSqlNativeConnStr(string server, string database, string username, string password)
  6. {
  7. return string.Format("Data Source={0};Initial Catalog={1};Integrated Security=False;User Id={2};Password={3};",
  8. server,
  9. database,
  10. username,
  11. password);
  12. }
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Oct 19th, 2009
0
Re: Connection to remote SQL Database problem in app
Hello again. thanks for reply. Can you please advise me step by step how to create such db i need.

I made this:

1. Created db in SQL 2008 Express
2. Created an empty table (ID,Name...there will be no any use of it)
3. In Object Explore > Security > Credentials created new credential with Username Password.
4. In Object Explore > Logins created new login and password with the same logs and passes as my new credential.
5. Saved database.
6. From Microsoft SQL Server > MSSQL.1>MSSQL>DATA copied RemoteDB.mdf on the desctop and that after sent this file by FTP into remote webserver. Placed him in root.
7. In my program changed connection string as sknake has adviced.
8. tried to connect. Alas, the same problem cannot connect and throws me MessageBox (exeption) "Login failed for user 'NathanBase'."

Where have I went wrong?
Last edited by Nfurman; Oct 19th, 2009 at 5:04 pm.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Nfurman is offline Offline
69 posts
since Oct 2009
Nov 13th, 2009
0
Re: Connection to remote SQL Database problem in app
Can you post the existing connection string? Of course, removing any confidential information.
Reputation Points: 10
Solved Threads: 3
Light Poster
sanch01r is offline Offline
30 posts
since Oct 2009
Jan 5th, 2010
0
Re: Connection to remote SQL Database problem in app
Ok guys. thank you for answers. the way to resolve this problem I found by myself.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Nfurman is offline Offline
69 posts
since Oct 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: old Array into Choice of New Array
Next Thread in C# Forum Timeline: C# and XML





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC