The connection string is not a parameter although it is shown in the example #region UpdateDataset /// /// Executes the respective command for each inserted, updated, or deleted row in the DataSet. /// /// /// e.g.: /// UpdateDataset(conn, insertCommand, deleteCommand,
updateCommand, dataSet, "Order"); /// /// A valid transact-SQL statement or stored procedure to insert new records into the data source /// A valid transact-SQL statement or stored procedure to delete records from the data source /// A valid transact-SQL statement
or stored procedure used to update records in the data source /// The DataSet used to update the data source /// The DataTable used to update the data source. public static void UpdateDataset(SqlCommand insertCommand, SqlCommand deleteCommand, SqlCommand updateCommand,
DataSet dataSet, string tableName) { if( insertCommand == null ) throw new ArgumentNullException( "insertCommand" ); if( deleteCommand == null ) throw new ArgumentNullException( "deleteCommand" ); if( updateCommand == null ) throw new ArgumentNullException(
"updateCommand" ); if( tableName == null || tableName.Length == 0 ) throw new ArgumentNullException( "tableName" ); // Create a SqlDataAdapter, and dispose of it after we are done using (SqlDataAdapter dataAdapter = new SqlDataAdapter()) { // Set the data
adapter commands dataAdapter.UpdateCommand = updateCommand; dataAdapter.InsertCommand = insertCommand; dataAdapter.DeleteCommand = deleteCommand; // Update the dataset changes in the data source dataAdapter.Update (dataSet, tableName); // Commit all the changes
made to the DataSet dataSet.AcceptChanges(); } } #endregion
DavidRhodes
Participant
801 Points
187 Posts
Bug in UpdateDataset
Mar 18, 2004 01:25 PM|LINK
DarrellNorto...
All-Star
86555 Points
9624 Posts
Moderator
MVP
Re: Bug in UpdateDataset
Mar 18, 2004 09:26 PM|LINK
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.
DavidRhodes
Participant
801 Points
187 Posts
Re: Bug in UpdateDataset
Mar 19, 2004 06:17 PM|LINK