这样也报错
this.sqlDr_other.SelectCommand.Connection = new System.Data.SqlClient.SqlConnection("Data source=127.0.0.1;initial catalog=sms;user id=sa;password=000000;");//这里报错,“未将对象引用设置到对象的实例”,this.sqlDr_other.SelectCommand.Connection.Open();

解决方案 »

  1.   

    你看看在
    try
    {}
    catch(Exception ex)
    {
    MessageBox.Show(ex.Message);
    }
      

  2.   

    Data source=127.0.0.1
    改为Data source=你的机器名
    或者Data source=(local)
    试试
      

  3.   

    to 楼主:
       你可能的问题:
        1:sql server没有启动
        2:你的连接语句有问题,或者数据库不存在
            string conn_str="server=yourserver;user id=user;password=pwd;
                             database=yourdb;";
             SqlConnection conn=new SqlConnection(conn_str);
             string sql="select * from table"
             try{
                conn.Open();
                SqlCommand comm=new SqlCommand();
                comm.ConnectionString=conn;
                comm.ContentString=sql;
                ...
                conn.Close();
               }
             catch(Exception ee){
                   MessageBox.Show(ee.Message);
              }另外你的结构写的好象也不太好,最好把连接数据库的信息放到config文件中                                               wish u good luck
                                                         Greatsft
      

  4.   

    没次打开前conn 前最好先判断一下,是否是 open 然后再打开,最后要记的关闭。Disponse
      

  5.   

    楼主用查询分析器连接一下,是不是Sqlserver连接不上。
      

  6.   

    "未将对象引用设置到对象的实例",从错误提示上看,你没有构造new SqlDataAdapter(),应该是少了
    sqlDr_other=new System.Data.SqlClient.SqlDataAdapter();这一句。
      

  7.   

    不知道怎么搞的莫名其妙的又好使了!
    我的sqlDr_other是从工具栏中拖出来的,应该没什么问题
    SQLSERVER启动了,连接字符串也好使。我用DELPHI怎么写都没问题!郁闷!
    谢谢大家了!结贴了!