If you build any table prior to executing the FillDataSet method, the SQLDataAdapter object will simply fill the existing table.
To specify your own INSERT statement, which should be executed when the Update method is called on the DataAdapter object, set the InsertCommand property. The DataAdapter object will execute the specified Insert command to insert the rows in the database. You can use a parameterized Insert query or a stored procedure to set the InsertCommand property.
When using the SQL managed provider, you have to use named parameters in the
parameterized query. There is a difference when using parameters with the
You need to set the SourceColumn property for all the parameters. The SourceColumn property tells the DataAdapter object which column in the table is going to provide its value. Set it to the actual parameter name:
And as I was reading on SourceColumn I wondered about how the DataAdapter know which table it should populate, and how to name the tables and columns in a DataSet, so …
This is the way the DataAdapter maps the database to the dataset. Some points need attention here:
· First the default DataTableMapping is called “table”
· We can use that to change the default names and mappings using the name “table”
· Second we need not specify the DataColumnMapping for all the cols
· If we don’t the unmapped columns will be named the same as the original ColumnName in the database