Link to home
Start Free TrialLog in
Avatar of GoldenJag
GoldenJag

asked on

update field in database using dataset

I am trying to update a field in the database using datasets.  The acceptchanges() doesnt seem to be working like i thought it would.  How do i accomplish the update?

The code is below:

DataSet CHEnroll= new DataSet();

switch(ddlFileFormat.SelectedIndex)
{
      case 0:       //Enrollment
      CHEnroll = GetVEnroll(strCardHolderStatus);
      break;
                                :
                                :
}            

DataRow vEnroll = CHEnroll.Tables[0].Rows[0];  //rstCardHolder

if (CHEnroll.Tables[0].Rows.Count>0)
{
      foreach (DataRow ch in CHEnroll.Tables[0].Rows)
      {
            ch["CardHolderStatus"]="EnrollPending";
            ch.AcceptChanges();
                 }
}
Avatar of Sirees
Sirees

Try to replace
ch.AcceptChanges() with  CHEnroll.AcceptChanges()

invoking AcceptChanges on the DataSet causes AcceptChanges to be called on each table within the DataSet.
ASKER CERTIFIED SOLUTION
Avatar of ibost
ibost

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GoldenJag

ASKER

Thanks ibost.

I think i will create an update function because my program is set up on using stored procedures.  Thanks for informing me that i cant use AcceptChanges to update a database.


GoldenJag