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] 服务器名称,一般添机器的IP
strcons[1]协议DBMSSOCN(为tcp/ip协议)
strcons[2]]端口号,一般为1433
strcons[3] 数据库名
strcons[4] 用户名
strcons[5]密码
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.