I found some sample code (below) that will handle all the update logic for a
dataset. All you need to pass is the dataset, the tablename, & the name of
the table in the db. Problem is, in our ASP.NET app, our dataset is bound
to a grid. But how is it updated? If I send it to the SaveDataSet function
below, the dataset will have the same original data that was retrieved into
the grid. How does one update the dataset :) ? Thats my rediculous
question. Thanks for any help! -- Jason Shohet



public override int SaveDataSet(DataSet ds, string Tablename, string
DatabaseTablename)
{
int RowsUpdated = -1;
this.SetError();

if (!this.Open())
return -1;

this.LoadDataAdapterCommands( new OleDbCommand("SELECT * FROM "
+DatabaseTablename), ref this.DataAdapter);

if (this.Transaction != null)
{
this.DataAdapter.InsertCommand.Transaction = this.Transaction;
this.DataAdapter.UpdateCommand.Transaction = this.Transaction;
this.DataAdapter.DeleteCommand.Transaction = this.Transaction;
}

/// update & return # of rows updated
try
{
RowsUpdated = ((SqlDataAdapter) this.DataAdapter).Update(ds,
ds.Tables[Tablename].ToString());
}
catch(Exception ex)
{
this.SetError(ex.Message);
return -1;
}

return RowsUpdated;
}

public override bool LoadDataAdapterCommands(IDbCommand SelectCommand,ref
IDbDataAdapter Adapter)
{
if (Adapter == null)
Adapter = this.CreateDataAdapter(SelectCommand);

SqlCommandBuilder CommandBuilder= new
SqlCommandBuilder((SqlDataAdapter) Adapter);

Adapter.SelectCommand = SelectCommand;
Adapter.DeleteCommand = CommandBuilder.GetDeleteCommand();
Adapter.UpdateCommand = CommandBuilder.GetUpdateCommand();
Adapter.InsertCommand = CommandBuilder.GetInsertCommand();

return true;
}