显然是连接字符串没写对.自己查
http://connectionstrings.com/

解决方案 »

  1.   

    字符串不对
    string ConnectionString = "data source=localhost;initial catalog=DatabaseName;integrated security=SSPI;user ID=sa;password=123456";
      

  2.   

    Db.ConnectionString 是从哪里读取的,查看原链接字符串是否正确! 字符串连接如楼上的。
      

  3.   


    public SqlDataReader GetList(string Sql) 

    string ConnectionString = "data source=localhost;initial catalog=DatabaseName;integrated security=SSPI;user ID=sa;password=123456";
    SqlConnection myConnection = new SqlConnection(ConnectionString); 
                    SqlCommand myCommand = new SqlCommand(Sql, myConnection); myConnection.Open(); 
    SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection); 
    return result; 
      

  4.   

     public class Database
        {
            protected string strconnection;
            protected SqlConnection conn;
            public Database()
            {
                strconnection = ConfigurationManager.ConnectionStrings["zilong"].ConnectionString;
            }
            protected void Open() //保护方法,打开连接
            {            if (conn == null)
                {
                    conn = new SqlConnection(strconnection);
                }
                if (conn.State.Equals(ConnectionState.Closed))
                {
                    conn.Open();
                }
            }
      public void Close()
            {
                if (conn.State.ToString() == "Open")
                {
                    conn.Close();
                }
            }
    public SqlDataReader GetList(string Sql) 
    { Open(); 
    SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection); 
    return result;