ADO.net ExecuteNonQuery

Go back to: Code Samples
DBConn.Open();
DBTxn = DBConn.BeginTransaction();
 
// Set the Connection property of the Command object
DBCmd.Connection = DBConn;
 
// Set the text of the Command to the INSERT statement
DBCmd.CommandText = "INSERT into employees VALUES (
                     15, 'HAYES', 'ADMIN', 6, " + 
                     "'17-APR-2002', 18000, NULL, 4)";
 
// Set the transaction property of the Command object
DBCmd.Transaction = DBTxn;
 
// Execute using ExecuteNonQuery because we do not 
// retrieve a result set
DBCmd.ExecuteNonQuery();
 
// Commit the transaction
DBTxn.Commit();
 
// Close the connection
DBConn.Close();




Like what you see? Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • LinkedIn
  • Reddit
  • StumbleUpon
  • Technorati
  • TwitThis

Book Content Copyright © 2009 by Prentice Hall PTR. All rights reserved. | Corporate Sponsor DataDirect Technologies.