conn.state值是1,但执行查询却查不出数据,非得关掉重open才行

解决方案 »

  1.   

    查询的时候有报错吗?如果网络断开 conn.state 是没有办法捕获到的
      

  2.   

    上次查询没有关闭吧 SqlConnection conn = new SqlConnection(ConfigurationManager.
                                         ConnectionStrings["FolktaleDBConnectionString"].ConnectionString);
                     conn.StateChange += new StateChangeEventHandler(conn_StateChange);
                     SqlCommand cmd1 = new SqlCommand("select * from classification", conn);              
                     SqlDataAdapter adaper1 = new SqlDataAdapter(cmd1);
                     
                     SqlCommandBuilder cmdBuilder1 = new SqlCommandBuilder(adaper1);
                                      DataSet ds = new DataSet();                 try
                     {
                         conn.Open();
                         adaper1.FillSchema(ds, SchemaType.Mapped, "Classification");
                        
                         adaper1.Fill(ds, "Classification");
                                         }
                     catch (Exception ex)
                     {
                         Console.WriteLine(ex.Message);
                     }
                     finally 
                     {
                         conn.Close();
                     }
      

  3.   

     是不是执行的 update语句 哪么加一个sleep(100)