Connection to remote SQL Database problem in app

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2009
Posts: 2
Reputation: Nfurman is an unknown quantity at this point 
Solved Threads: 0
Nfurman Nfurman is offline Offline
Newbie Poster

Connection to remote SQL Database problem in app

 
0
  #1
Oct 10th, 2009
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.


  1. SqlConnection sqlconn = new SqlConnection("Data Source=64.191.121.53,1433;Network Library=DBMSSOCN;Initial Catalog=remoteDB;User ID=guest;Password=;");
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 28
Reputation: sanch01r is an unknown quantity at this point 
Solved Threads: 2
sanch01r sanch01r is offline Offline
Light Poster
 
0
  #2
Oct 18th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,437
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 624
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast
 
0
  #3
Oct 19th, 2009
You also need to set "Integrated Security=False;" when using a username/password connection string. Here are example connection string builders:
  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. }
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 2
Reputation: Nfurman is an unknown quantity at this point 
Solved Threads: 0
Nfurman Nfurman is offline Offline
Newbie Poster
 
0
  #4
Oct 19th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 28
Reputation: sanch01r is an unknown quantity at this point 
Solved Threads: 2
sanch01r sanch01r is offline Offline
Light Poster
 
0
  #5
Nov 13th, 2009
Can you post the existing connection string? Of course, removing any confidential information.
Reply With Quote Quick reply to this message  
Reply

Tags
app, c#, connection, remote, sql

Message:




Views: 1504 | Replies: 4
Thread Tools Search this Thread



Tag cloud for app, c#, connection, remote, sql
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC