直接将cmd定义成Adapter的实例:
SqlDataAdapter cmd = new SqlDataAdapter("sp_update_spTest",cn);

//dataAdapter.UpdateCommand = cmd;
注释掉
试试看!!

解决方案 »

  1.   

    然后
    cmd.Update(dataSet,"spTest");
      

  2.   

    do not call 
    dataSet.AcceptChanges();
    before you update the database, otherwise, the database will think you have nothing to update
      

  3.   

    actually, not "the database will think you have nothing to update", ADO.NET will think you have nothing to update
      

  4.   

    SqlCommand cmd = new SqlCommand("sp_update_spTest",cn);
    cmd.CommandType = CommandType.StoredProcedure ;
    cmd.Parameters.Add(new SqlParameter("@id",SqlDbType.Int));
    cmd.Parameters.Add(new SqlParameter("@no",SqlDbType.Char,10));
    cmd.ExecuteNonQuery()
      

  5.   

    SqlCommand cmd = new SqlCommand("sp_update_spTest",cn);
    cmd.CommandType = CommandType.StoredProcedure ;
    cmd.Parameters.Add(new SqlParameter("@id",SqlDbType.Int));
    cmd.Parameters.Add(new SqlParameter("@no",SqlDbType.Char,10));cmd.CommandText = 存储过程名;
    string myConnectionString = "data source=cxj;initial catalog=master;user id=sa;password=";
    SqlConnection  myConnection = new SqlConnection(myConnectionString);
    cmd.Connection = myConnection;
    myConnection.Open();
    cmd.ExecuteNonQuery();
    dataSet.AcceptChanges();
    myConnection.Close();
      

  6.   

    cmd.Parameters.Add(new SqlParameter("@id",SqlDbType.Int));
    cmd.Parameters["@id"].value=?
    cmd.Parameters.Add(new SqlParameter("@no",SqlDbType.Char,10));
    cmd.Parameters["@no"].value=?如果你的数据是从dataSet.Table("spTest")来的那么
    new SqlParameter("@id",SqlDbType.Int,
                     4, "id")
    格式来写
    注意名称要对应
      

  7.   

    我的存储过程的参数就是DATASET中表的数据
    用COMMAND。EXECUTE只能存一条记录
      

  8.   

    .net sdk 文挡中有详细的说明
    ms-help://MS.NETFrameworkSDK.CHS/cpguidenf/html/cpconupdatingdatabasewithdataadapterdataset.htm
      

  9.   

    你已经AcceptChange了,当然更新不了,此时DataSet中已经没有要更新的行了。
    AcceptChange把放到最后。
      

  10.   

    不要AcceptChange
    结贴
    谢谢大家
    new SqlParameter("@id",SqlDbType.Int)改为
    new SqlParameter("@id",SqlDbType.Int,4, "id")