//不使用远程连接的时候应该把连接字符串改为:
"Server=localhost//SQLExpress;Integrated Security=SSPI"
//也可以指定默认的数据库,例如,指定默认数据库是"master"就应该写为:
"Server=localhost//SQLExpress;Initial Catalog=master;Integrated Security=SSPI"
或者:"Server=localhost//SQLExpress;Initial Catalog=master;Uid=sa;Pwd=sa"
B/S模式连接数据库:
string sql="Source=服务器Ip;database=数据库名称;UID=sa;Password=sasa;";
C/S模式连接数据库:
string sql="Data Source=服务器Ip;Initial Catalog=数据库名称;User ID=sa;password=sa";