Doubt regarding SqlCommand object
-
Hello all, I want to know, can we insert multiple records at the same time using any method of SqlCommand class? If this is possible then how can we achieve it? Thanks, Nagendra.
-
Hello all, I want to know, can we insert multiple records at the same time using any method of SqlCommand class? If this is possible then how can we achieve it? Thanks, Nagendra.
SQLCommand does not tackle this as it is only resposible for passing on the execution statement to the server. Here [^]is a nice article for doing this.
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
SQLCommand does not tackle this as it is only resposible for passing on the execution statement to the server. Here [^]is a nice article for doing this.
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
Hi You can use BatchUpdate for this try { Craete SQL COmmand Object cmd.CommandType = CommandType.StoredProcedure; cmd.UpdatedRowSource = UpdateRowSource.None; cmd.Parameters.Add("@Param1", SqlDbType.Int, 4, argDt.Columns[0].ColumnName); cmd.Parameters.Add("@Pram2", SqlDbType.Bit, 5, argDt.Columns[1].ColumnName); cmd.CommandTimeout = 0; SqlDataAdapter da = new SqlDataAdapter(); da.InsertCommand = cmd; da.UpdateBatchSize = 100; conn.Open(); int recordsInserted = da.Update(argDt); conn.Close(); }
Inderjeet Kaur Sr. Software Engg