Solution: User 'sa 'logon fails. Cause: it is not associated with a trusted SQL server connection.
2008.3.31 today ASP. NET and SQL server connections (http://www.wecanwecan.com), authentication encountered this problem, so sort out my Solutions
For sharing with friends who have the same experience:
Problem description:
Server Configuration: WindowsXP framework2.0 sqlserver2000
User 'sa 'Login Failed. Cause: it is not associated with a trusted SQL server connection.
Note: An unhandled exception occurs during the execution of the current Web request. Check the stack trace information to learn about this error andCode
Detailed information about the cause of the error.
Exception details: system. Data. sqlclient. sqlexception: User 'sa 'Logon Failed. Cause: SQL is not trusted
Server connection.
Solution:
This problem is generally caused by SQL Server being integrated with Windows authentication, so the solution is:
1. Open the SQL Server Enterprise Manager.
2. Right-click the server name and select "properties". The "security" tab is displayed.
3. On the tab, select "SQL Server and Windows" for authentication.
The following error may occur:
An error has occurred while establishing a connection to the server. When connecting to SQL
Server 2005, this failure may be caused by the fact that under the default settings SQL
Server does not allow remote connections. (provider: Named Pipes provider, error: 40-cocould
Not open a connection to SQL Server)
Exception details: system. Data. sqlclient. sqlexception: An error occurred while establishing a connection with the server. When you connect to SQL Server 2005, the default setting does not allow remote connection to SQL Server may cause this failure. (Provider: named pipeline providesProgram, Error: 40-unable to open the connection to SQL Server)
Solution:
Check and find the problem is webconfig configuration. Change Server = Local or the name of the local computer to solve the problem.
(Note: Make sure that the account password used to log on to ms SQL Server is consistent with the configuration in the web. config file)
For example:
<Connectionstrings>
<! -- Link the link string of the SQL Server database -->
<Add name = "mispersonalconn" connectionstring = "Data
Source = 192.168.133.31; database = db_mispersonal; uid = sa; Pwd = ;"
Providername = "system. Data. sqlclient"> </Add>
</Connectionstrings>
Note:
Database connection string
Data Source = computer name/IP \ sqlexpress; attachdbfilename = | datadirectory | database file name. MDF; Integrated Security = true; Connect timeout = 30; user instance = false
For example:
Data Source =. \ sqlexpress; attachdbfilename = | datadirectory | dB. MDF; Integrated Security = true; Connect timeout = 30; user instance = false
You do not need to attach a database to MSSQL
Another method (to attach a database to MSSQL): Data Source = computer name/IP; database = database name; uid = sa; Pwd = password ;"
The IP address can be 127.0.0.1 or local or.