asp.net.ph

OleDbDataAdapter.InsertCommand Property

System.Data.OleDb Namespace   OleDbDataAdapter Class


Sets or retrieves an SQL statement used to insert new records into the data source.

[ VB ]
Public Property InsertCommand As OleDbCommand

[ C# ]
public OleDbCommand InsertCommand {get; set;}

[ C++ ]
public: __property OleDbCommand* get_InsertCommand ( );
public: __property void set_InsertCommand ( OleDbCommand* );

[ C++ ]
public function get InsertCommand ( ) : OleDbCommand;
public function set InsertCommand ( OleDbCommand );

Property Value

An OleDbCommand used during Update to insert records in the data source that correspond to new rows in the DataSet.

Remarks

During Update, if this property is not set and primary key information is present in the DataSet, the InsertCommand can be generated automatically if you set the SelectCommand property and use the OleDbCommandBuilder. Then, any additional commands that you do not set are generated by the OleDbCommandBuilder. This generation logic requires key column information to be present in the DataSet. For more information see Automatically Generated Commands.

When InsertCommand is assigned to a previously created OleDbCommand, the OleDbCommand is not cloned. The InsertCommand maintains a reference to the previously created OleDbCommand object.

NOTE: If execution of this command returns rows, these rows may be added to the DataSet depending on how you set the UpdatedRowSource property of the OleDbCommand object.

Example

The following example initializes an OleDbDataAdapter and sets some of its properties.

string myConn = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=gear.mdb";
string query = "SELECT * FROM Products ORDER BY ProductID";

OleDbDataAdapter myDataAdapter = new OleDbDataAdapter ( query, myConn );
myDataAdapter.InsertCommand.CommandText = 
   "INSERT INTO Products VALUES ( 'Supplies','Cookware','campstove.jpg' ) ";
myDataAdapter.InsertCommand.Connection = 
   myDataAdapter.SelectCommand.Connection;
  C# VB

See Also

OleDbDataAdapter Members   DeleteCommand   SelectCommand   UpdateCommand Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph