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.

SqlConnection sqlconn = new SqlConnection("Data Source=64.191.121.53,1433;Network Library=DBMSSOCN;Initial Catalog=remoteDB;User ID=guest;Password=;");

Recommended Answers

All 5 Replies

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.

You also need to set "Integrated Security=False;" when using a username/password connection string. Here are example connection string builders:

public static string BuildSqlNativeConnStr(string server, string database)
    {
      return string.Format("Data Source={0};Initial Catalog={1};Integrated Security=True;", server, database);
    }
    public static string BuildSqlNativeConnStr(string server, string database, string username, string password)
    {
      return string.Format("Data Source={0};Initial Catalog={1};Integrated Security=False;User Id={2};Password={3};", 
        server, 
        database,
        username,
        password);
    }

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?

Can you post the existing connection string? Of course, removing any confidential information.

Ok guys. thank you for answers. the way to resolve this problem I found by myself.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.