日期:2014-05-18  浏览次数:20982 次

不支持关键字: “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)));

------解决方案--------------------
探讨

如果servername 改成server的话 那 host 就是不支持的关键字