Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.

 最近在VS2008中编写asp.net程序,其中在连接数据库的时候出现了:

Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.

 

我的连接字符串为:conn.ConnectionString = "server=pc-201007021400\wincc;uid=;pwd=;database=" & filename

看来是uid出现了错误,然后改成:conn.ConnectionString = "server=pc-201007021400\wincc;uid=sa;pwd=123456;database=" & filename

这里sa和123456是在sql server中进行设置的,这样改后可以正常连接到数据库了。

你可能感兴趣的:(Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.)