views:

404

answers:

1

I am updating the sql server 2005 database using batch update, as shown below

 cmd = new SqlCommand("update Table1 set column1 = @column1 where EmpNo = @EmpNo", con);
                cmd.Parameters.Add(new SqlParameter("@column1", SqlDbType.VarChar));
                cmd.Parameters["@column1"].SourceVersion = DataRowVersion.Current;
                cmd.Parameters["@column1"].SourceColumn = "Column";

                cmd.Parameters.Add(new SqlParameter("@EmpNo", SqlDbType.Int));
                cmd.Parameters["@EmpNo"].SourceVersion = DataRowVersion.Current;
                cmd.Parameters["@EmpNo"].SourceColumn = "EmpNo";

                cmd.UpdatedRowSource = UpdateRowSource.None;

                sqlDa = new SqlDataAdapter();
                con.Open();
                sqlDa.UpdateCommand =cmd;
                sqlDa.UpdateBatchSize = 10;
                sqlDa.Update(dt);

                con.Close();

But the data is not updated.I am unable to figure out what is the problem.Any help is appreciated.

+1  A: 

I would suggest that you look at the dt right before you issue the update command. Make sure there are some rows that have RowState of Updated or Added. If not, there's nothing in your (I'm assuming) DataTable to update to the database.

Also, try removing the .SourceVersion property set operation.

If everything looks good, start a trace on the database right before you issue the .Update.

These are just a couple first steps to try.

Mark A Johnson