Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch updating DataSet help

Status
Not open for further replies.

Vachaun22

Programmer
Oct 7, 2003
171
US
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:

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.
 
Code:
foreach(DataRow row in objDS.Tables[0].Rows)
{
   Row["MyFieldName"] += fAmount;
}

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top