Server|sql
This article describes in detail how C # implements remote connection SQL Server2005 steps.
First Configure SQLSERVER2005:
Open Microsoft SQL Server Management Studio directly to the Windows user connection, and then, in security, "new login" in the login name, you can add "OK" to the corresponding.
Then in your corresponding "database" in the "security" user, you build the user to add in.
Critical place, view server properties on security Select the SQL Server and Windows authentication mode point "OK" system prompts you to restart SQL Server you can "stop" and restart.
Then look at the code statement for C # connecting SQL Server2005:
Strcon = Strcon + @ "Data source=" + Strcons[0];strcon = Strcon + "," + strcons[2] + "; Strcon = Strcon + "Network library=" + strcons[1] + ";"; Strcon = Strcon + "Initial catalog=" + strcons[3] + ";"; Strcon = Strcon + "User id=" + strcons[4] + ";"; Strcon = Strcon + "password=" + strcons[5] + ";"; Strcon = Strcon + "Persist security info=true"; strcons[0] Server name, General Tim Machine Ipstrcons[1] Protocol DBMSSOCN (for TCP/IP protocol) strcons[2]] port number , typically 1433strcons[3] database name strcons[4] User name strcons[5] Password
|
Port number should also be configured:
SQL Server 2005 Network configuration in SQL Server configuration management in the services and applications in Control Panel
The SERVER2005 protocol TCP/IP defaults to Disabled, and its properties set its port number to 1433 "OK" to start.