不支持关键字: “servername”。
// private static string ConnStr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
private static string ConnStr = "UID=DBA;PWD=3jw9lketj;Database=caredb;ServerName=localdb;Server=192.168.1.5";
private static SqlConnection conn;
private static SqlConnection Conn
{
get
{
if (conn == null)
{
conn = new SqlConnection(ConnStr);
conn.Open();
}
else if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
else if (conn.State == ConnectionState.Broken)
{
conn.Close();
conn.Open();
}
return conn;
}
}
------解决方案--------------------C# code
DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SID=MYSID)(SERVER=DEDICATED)));
------解决方案--------------------