代码如下private void DataSetOperator(DataSet ds, string filePath)
    {
        string con = ConfigurationManager.ConnectionStrings["gongziConnectionString"].ConnectionString;
        SqlConnection conn = new SqlConnection(con);
        conn.Open();
        SqlTransaction str = conn.BeginTransaction();//利用事务处理 防止中断        
        int k = 0;
        //Response.Write(ds.Tables[0].Rows.Count);
        if (ds.Tables[0].Rows.Count < 1)
        {
            Response.Write("<script>alert('没有数据!')</script>");
            return;
        }
        try
        {
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                string sqlStr = "insert into 汇总工资 (姓名,工资,奖金,零星收入,备注)values ('" + ds.Tables[0].Rows[i][0].ToString() + "','" + ds.Tables[0].Rows[i][1].ToString() + "','" + ds.Tables[0].Rows[i][2].ToString() + "','" + ds.Tables[0].Rows[i][3].ToString() + "','" + ds.Tables[0].Rows[i][4].ToString() + "')";
                SqlCommand cmd = new SqlCommand(sqlStr, conn, str);
                cmd.Transaction = str;
                k+= cmd.ExecuteNonQuery();
                //Response.Write(k);
            }
            str.Commit();
        }
        catch (Exception ex)
        {
            Label1.Text = "发生异常,数据已回滚 信息" + ex.Message;
            //Response.Write("发生异常,数据已回滚 信息" + ex.Message);
            str.Rollback();
        }
        finally
        {
            Label2.Visible = true;
            Label3.Visible = true;
            Label2.Text = "上传成功";
            Label1.Text = Convert.ToString(k);
            Label3.Text = "条";
            //Response.Write("上传成功" + k + "条");
            File.Delete(filePath);
        }
    }ds.Tables[0].Rows.Count
能读出来正确的行数,但是实际导入的时候只能导入32行,不知道原因,请大神们指教。