I need to batch update records in a dataset. I was familiar with how to do this with ADO using Ado.RecordSet objects, but I'm a bit lost with ADO.NET and the System.Data.DataSet object.
The code:
The comments in the code is what I'm trying to accomplish, but am not sure how. Essentially it's to be a checkbook register, and if a transaction is entered after transactions that occurred after it, I need it to find all those records, and update their running balances from that point on.
Hopefully that makes sense.
The code:
Code:
private bool Update_Transactions ( int iCompanyID, DateTime dtDate, int iType, float fAmount )
{
if ( iType == CREDIT )
{
try {
if ( objConn.State != ConnectionState.Open )
objConn.Open();
DataSet objDS = new DataSet ();
string SQL = "SELECT * FROM TRANSACTIONS WHERE TRANS_TYPE = " +
"@TYPE AND TRANS_DATE >= @DATE ORDER BY TRANS_DATE;";
SqlDataAdapter objDA = new SqlDataAdapter ( SQL, objConn );
objDA.Fill ( objDS, "TRANSACTIONS" );
[COLOR=green]
// At this point I need to start at the beginning of the
// DataSet, and add or subtract fAmount from the AMOUNT
// field in the table. This will be done until the
// end of the recordset is reached. At this point, I
// simply need to submit these changes back to the
// database. But I'm stuck and I'm not sure how to do it
// with a DataSet.
[/color]
}
}
else
{
}
}
The comments in the code is what I'm trying to accomplish, but am not sure how. Essentially it's to be a checkbook register, and if a transaction is entered after transactions that occurred after it, I need it to find all those records, and update their running balances from that point on.
Hopefully that makes sense.