C#如何连接SqlServer2005非默认实例

时间:2022-02-23 05:01:04

server=IP,PORT  如127.0.0.1,1433(用逗号分割IP与端口)

<add name="SqlConn" connectionString="Data Source=127.0.0.1,1433;Initial Catalog=aa;Persist Security Info=True;User ID=sa;Password=123" providerName="System.Data.SqlClient"></add>


或者用“服务器名\实例名”

<add name="SqlConn" connectionString="Data Source=Service\SQLEXPRESS;Initial Catalog=aa;Persist Security Info=True;User ID=sa;Password=123" providerName="System.Data.SqlClient"></add>