Connecting to SQL server from another computer

僤鯓⒐⒋嵵緔 提交于 2019-12-06 10:15:39

问题


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


回答1:


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.




回答2:


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=-----");


来源:https://stackoverflow.com/questions/9738629/connecting-to-sql-server-from-another-computer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!