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.Selec tedIndex)
{
case 0: //Enrollment
CHEnroll = GetVEnroll(strCardHolderSt atus);
break;
:
:
}
DataRow vEnroll = CHEnroll.Tables[0].Rows[0] ; //rstCardHolder
if (CHEnroll.Tables[0].Rows.C ount>0)
{
foreach (DataRow ch in CHEnroll.Tables[0].Rows)
{
ch["CardHolderStatus"]="En rollPendin g";
ch.AcceptChanges();
}
}
The code is below:
DataSet CHEnroll= new DataSet();
switch(ddlFileFormat.Selec
{
case 0: //Enrollment
CHEnroll = GetVEnroll(strCardHolderSt
break;
:
:
}
DataRow vEnroll = CHEnroll.Tables[0].Rows[0]
if (CHEnroll.Tables[0].Rows.C
{
foreach (DataRow ch in CHEnroll.Tables[0].Rows)
{
ch["CardHolderStatus"]="En
ch.AcceptChanges();
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
updating database with Adapter and dataset
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconUpdatingDatabaseWithDataAdapterDataSet.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconUpdatingDatabaseWithDataAdapterDataSet.asp
ch.AcceptChanges() with CHEnroll.AcceptChanges()
invoking AcceptChanges on the DataSet causes AcceptChanges to be called on each table within the DataSet.