你将drl.Close();写到while(drl.Read()){}外面试试

解决方案 »

  1.   

    还有
    myConnection.Close();
    myConnection.Dispose();
    都写到外面
      

  2.   

    哇赛!
    这么多的代码阿
    看的我都晕了!
    就是 yqdeng(享受生活每一天) 说的那样
      

  3.   

    while(dr1.Read())
    {
    int sscount =  Int32.Parse(dr1["sfromcount"].ToString());
    int ssscount=sscount;
    dr1.Close();
    int countnumber1=ssscount+1;
    string sSqlCommand1="update mobilenumber set stime='"+timeTempString+"',sfromcount="+countnumber1+" where number='"+number1+"'";
    SqlCommand myCommand1=new SqlCommand(sSqlCommand1,myConnection);
    myCommand1.ExecuteNonQuery();
    myConnection.Close();
    myConnection.Dispose(); }dr1.Read() 时,你执行dr1.Close();
    myConnection.Close();
    myConnection.Dispose();????
    ??
      

  4.   

    1,string execString = "select sfromcount from mobilenumber where number='"+numbers+"'";  //number字段是数字还是字符,如果是数字就不要加单引号。
    2,string sSqlCommand1="update mobilenumber set stime='"+timeTempString+"',sfromcount="+countnumber1+" where number='"+number1+"'"; //stime是什么类型,参看number说明。
    3,string sSqlCommand1="update mobilenumber set stime='"+timeTempString+"',sfromcount="+countnumber1+" where number='"+number1+"'";  //加到myConnection.Open();之前。
    4,try  //看看什么错。
    {
       myCommand1.ExecuteNonQuery();
    }
    catch{Exception ex}
    {
       MessageBox.Show(ex.Message)
    }
      

  5.   

    把你的while循环改成如下:
    int sscount =-1;
    if(dr1.Read())
    {
       sscount=Int32.Parse(dr1["sfromcount"].ToString());
    }
    dr1.Close();if(sscount>0)
    {
    int ssscount=sscount;
    int countnumber1=ssscount+1;
    string sSqlCommand1="update mobilenumber set stime='"
    +timeTempString+"',sfromcount="+countnumber1+" where number='"+number1+"'";
    SqlCommand myCommand1=new SqlCommand(sSqlCommand1,myConnection);
    myCommand1.ExecuteNonQuery();
    }
    myConnection.Close();
    myConnection.Dispose();