Ahmed Kato
Ahmed Kato

Reputation: 1707

Connecting to SQL server from another computer

I am using c# to connect to sql server on another computer on the network but i got an exception message Login failed for user ' username' however the server log state that the connection is successful for the user using windows authentication my connection string is:

"Data Source=ipaddress,1433;Initial Catalog=database;Trusted_Connection=True;Integrated Security=False;Connect Timeout=30;user ID=username;password=password"

I am using microsoft sql server 2008 R2

Thanks in advance

Upvotes: 2

Views: 10228

Answers (2)

Saleem Kalro
Saleem Kalro

Reputation: 1142

Manage sa account in sql server with username= sa and set password=---- Use this connection string where 1433 is TCP Port

(Server=server_name,1433;Database=------;User ID=sa; Password=-----");

Upvotes: 0

Hoa Tran
Hoa Tran

Reputation: 271

There are few things you should check:

  1. Remove "Trusted_Connection=True;" in your connection string

  2. Turn off the firewall on both machines for testing. If it works, you can enable the both of them and then configure the access rights for specific application

  3. Enable SQL Authentication on SQL Server instance: http://kbase.gfi.com/showarticle.asp?id=KBID002804

  4. Simple way to test it works or not without running your c# code: you can install the SQL Management Studio on the code-machine and try to connect the SQL Server instance.

Hope it helps.

Upvotes: 2

Related Questions