WPF数据库连接错误:The user is not associated with a trusted SQL Server connection.
2014-04-01 10:59
701 查看
我当初安装sql server的时候选的Window Authentication mode,没选SQL Server Windows Authentication。
后来做WPF时连接数据库时需要一个带密码的用户,新建用户步骤如下:
1.打开Microsoft sql server management studioexpress,以Window Authentication mode方式登录,选Sercurity,右击Logins,选New Login...
2.然后如下图输入
记得db_owner也选上
3.右击已登录实例名,在左侧Select a page那里选Security,选SQL Server Windows Authentication
最后重启实例,右击实例名,选Restart.
新建实例后,打开VS,启动程序,在app.config文件中写连接语句
<connectionStrings>
<add name="ConnStr"
connectionString="Data Source=(local);Initial Catalog=FamilyFinancialSys;Persist Security Info=True;User ID=FamilyFinancial;Password=f123456"
providerName="System.Data.SqlClient" />
</connectionStrings>
点F5运行程序,如果还报错The user is not associated with a trusted SQL Server connection.
打开SQL Server Configuration Manager,如果你装过多个sql server,写Data Source=(local);会不知道选哪个连接,所以你得写明白到底连接的是哪个。
从Start中选Run(运行)输入services.msc,查看你正在运行的sql server是那个
连接语句改为
<connectionStrings>
<add name="ConnStr"
connectionString="Data Source=(写你自己的Server name);Initial Catalog=FamilyFinancialSys;Persist Security Info=True;User ID=FamilyFinancial;Password=f123456
providerName="System.Data.SqlClient" />
</connectionStrings>
后来做WPF时连接数据库时需要一个带密码的用户,新建用户步骤如下:
1.打开Microsoft sql server management studioexpress,以Window Authentication mode方式登录,选Sercurity,右击Logins,选New Login...
2.然后如下图输入
记得db_owner也选上
3.右击已登录实例名,在左侧Select a page那里选Security,选SQL Server Windows Authentication
最后重启实例,右击实例名,选Restart.
新建实例后,打开VS,启动程序,在app.config文件中写连接语句
<connectionStrings>
<add name="ConnStr"
connectionString="Data Source=(local);Initial Catalog=FamilyFinancialSys;Persist Security Info=True;User ID=FamilyFinancial;Password=f123456"
providerName="System.Data.SqlClient" />
</connectionStrings>
点F5运行程序,如果还报错The user is not associated with a trusted SQL Server connection.
打开SQL Server Configuration Manager,如果你装过多个sql server,写Data Source=(local);会不知道选哪个连接,所以你得写明白到底连接的是哪个。
从Start中选Run(运行)输入services.msc,查看你正在运行的sql server是那个
连接语句改为
<connectionStrings>
<add name="ConnStr"
connectionString="Data Source=(写你自己的Server name);Initial Catalog=FamilyFinancialSys;Persist Security Info=True;User ID=FamilyFinancial;Password=f123456
providerName="System.Data.SqlClient" />
</connectionStrings>
相关文章推荐
- java 连接 mssql2005 The user is not associated with a trusted SQL Server connection.
- The user is not associated with a trusted SQL Server Connection
- Login failed for user 'username'. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452) error
- The problem of the user is not associated with a trusted sql server connection 混合登录选项设置的问题
- Login failed for user 'sss'. The user is not associated with a trusted SQL Server connection.
- Login failed for user 'username'. The user is not associated with a trusted SQL Server connection
- The problem of the user is not associated with a trusted sql server connection 混合登录选项设置的问题
- Understanding the error message: “Login failed for user ''. The user is not associated with a trusted SQL Server connect
- Trouble shooting:login failed for user 'sa' ,the user is not associated with a trusted SQL Server
- This article provides a fix for the error: Login failed for user “. The user is not associated with a trusted SQL Server
- Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection. [SQLSTATE 28000] (Error 18452). The st
- Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
- Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.
- Login failed for user ''.Reason:Not associated with a trusted SQL Server connection.
- Login failed for user ''.Reason:Not associated with a trusted SQL Server connection.
- Login failed for user 'Tester'. Reason: Not associated with a trusted SQL Server connection.
- "Not associated with a trusted SQL Server connection"解决方法
- EF之数据库连接问题The specified named connection is either not found in the configuration, not intended to be used with the Ent
- Delphi使用BDE连接远程MS SQL SERVER 2000数据库时出现“Db-library network communciations layer not loaded.”错误的解决方法
- 如何解决sql连接错误HResult 0x2, Level 16, State 1 Could not open a connection to SQL Server [2].