public Database Db()
{
string serverName = "host\\SQLEXPRESS;";
string dbName = "db";
string username = "user";
string password = "123";
var connectionstring = "Data Source=" + serverName +
";Initial Catalog=" + dbName +
";User ID=" + username +
";Password=" + password +
";Max Pool Size=200;Pooling=true" +
";Connect Timeout=20";
return new Database(connectionstring , "System.Data.SqlClient");
}
这将返回如下内容:
string conn = Data Source=host\\SQLEXPRESS;
Initial Catalog=DbName;User ID=UserName;
Password=Pass;Max Pool Size=200;Pooling=true;Connect Timeout=20
错误显示找不到服务器或无法访问服务器我打开了某些端口并连接了几次但是上传应用程序后问题就开始了。
答案 0 :(得分:0)
试试这个:
string serverName = @".\SQLEXPRESS;";
string dbName = "db";
string username = "user";
string password = "123";
var connectionstring = "Data Source=" + serverName +
";Initial Catalog=" + dbName +
";User ID=" + username +
";Password=" + password +
";Max Pool Size=200;Pooling=true" +
";Connect Timeout=20";
稍微更改了serverName变量,我删除了分号。