OK.
I have something like this. If it doesnt make sense let me know!
using (SqlTransaction trans = sqlDataConnection.BeginTransaction())
{
try
{
for (int nLoop = 0 ; nLoop < sTblNames.Length ; nLoop++ )
{
string sTableName = sTblNames[nLoop] ;
if (null != dsChanges.Tables[sTableName])
{
string insSPName = "ins" + sTableName ;
string updSPName = "upd" + sTableName ;
string delSPName = "del" + sTableName ;
String[] strInsertParams =
GetParameterList(dtaAccessor.GetConnectionString, insSPName) ;
String[] strDeleteParams =
GetParameterList(dtaAccessor.GetConnectionString, delSPName) ;
String[] strUpdateParams =
GetParameterList(dtaAccessor.GetConnectionString, updSPName) ;
SqlCommand insertCmdApplicationHeader =
SqlHelper.CreateCommand( sqlDataConnection, insSPName ,
strInsertParams) ;
SqlCommand deleteCmdApplicationHeader =
SqlHelper.CreateCommand( sqlDataConnection, delSPName ,
strDeleteParams) ;
SqlCommand updateCmdApplicationHeader =
SqlHelper.CreateCommand( sqlDataConnection, updSPName ,
strUpdateParams) ;
//Using the DAAB blocks to update the database.
//Below seems to set all the dataset update/delete/insert
modifiers, so no further updates are
//Performed on the other tables
SqlHelper.UpdateDataset(trans,
insertCmdApplicationHeader,deleteCmdApplicationHeader,updateCmdApplicationHeader,
dsChanges, sTableName);
//This works, but doesn't return the updates, as the call to
GetChanges will result in another DataTable I imagine
SqlHelper.UpdateDataset(trans,
insertCmdApplicationHeader,deleteCmdApplicationHeader,updateCmdApplicationHeader,
dsChanges.Tables[sTableName].GetChanges(DataRowState.Modified |
DataRowState.Added | DataRowState.Deleted ));
//I'm using the cascade option within the Dataset to cascade the
Primary key though the data tables.
//The initial call to inset when no Key is present will tell the
SQL Stored Proc to create a key when writing the table
}
}
trans.Commit(); //Commit transaction...
}
}
Thanks for your time...
Cheers,