Problem in the connection string of Microsoft SQL Server 2005 !
I have MSSQLServer 2005 installed on my machine. I am creating a connection string like this:
String sqlConnectionString= user id=admin; password=admin; server=MachineName\MSSQLSERVER; Trusted_Connection=no; database=MYDataBase; connection timeout=30
When I do: myConnection = new SqlConnection(sqlConnectionString);
myConnection.Open();Open() command throws an exception :
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was no开发者_JS百科t found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 25
Also the same string works fine on SQLEXPRESS/
****I have configured Sql Express to accept remote connections by choosing "Local and remote connection".Also I started SQL Browswer service.****
Is there anything wrong in connection string?
You must have made a typo somewhere. Try this:
- Load up Visual Studio.
- Go to the "Server Explorer" tool window.
- Create a new data connection.
- Fill in your required values, click the "Test Connection" button to make sure they work, then click OK.
- Click on your new connection in the "Server Explorer", and you can copy and paste the connection string from the Properties tool window.
Have a look at http://www.connectionstrings.com/sql-server-2005
And verify that your names are correct.
Make sure that you have ‘SQL server and Windows Authentication mode’ set under ‘Server authentication’ in ‘Security’ properties. Your connection string implies that you are using SQL authentication. If you have ‘Windows Authentication mode’ set you may receive this error.
Try setting the server name to just the name of your machine, as in ‘server=MachineName;’.
精彩评论