0

Is there any API available similar to JDBC batch update [PreparedStatement.addBatch() and PreparedStatement.executeBatch() ]?

I have seen the DataAdapter. However I think it is using DataTable; is it similar to JDBC PreparedStatement?

Dalorzo
  • 19,834
  • 7
  • 55
  • 102
Rejeev Divakaran
  • 4,384
  • 7
  • 36
  • 36
  • possible duplicate of [How to perform batch update in Sql through C# code](http://stackoverflow.com/questions/2327081/how-to-perform-batch-update-in-sql-through-c-sharp-code) - though this question came first, the linked one actually has an answer – newfurniturey Sep 17 '12 at 13:42
  • There is alot of good tutorials on asp.net/Learn/data-access: [batched](http://www.asp.net/Learn/data-access/#batched). They use Strongly Typed DataSet, Transactions, Commits and Rollbacks. Worth Looking. – maxbeaudoin Aug 04 '09 at 15:46
  • Did you get a solution for this or was any of the answer helpful? – Jamie Clayton Dec 30 '13 at 00:46

1 Answers1

0

PreparedStatements in JDBC are directly analogous to SqlCommand, right down to supplying the statement and parameters. Here's an example:

    var cmd = "UPDATE SomeTable SET Value = @Param1 WHERE ID = @ID";

    using (var connection = new SqlConnection("Connection String Here"))
    using (var command = new SqlCommand(cmd, connection))
    {
        command.Parameters.AddWithValue("@Param1", "NewValue");
        command.Parameters.AddWithValue("@ID", 1);
        connection.Open();
        command.ExecuteNonQuery();
    }

From what I've read, all the above should see very familiar for someone who uses PreparedStatement.

ChokesMcGee
  • 166
  • 4