Click to See Complete Forum and Search --> : Changing data in DataSet


juresmith
February 10th, 2005, 02:50 AM
Hi friends,

I have one question about changing data in the DataSet. Whether changing data in DataSet in the manner described below is correct? Here is the code:

OleDbConnection* dbConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=myData.mdb");

OleDbDataAdapter* da = new OleDbDataAdapter("SELECT * FROM Customer", dbConn);

DataSet* ds = new DataSet("myDataSet");

// Fill the DataSet
da->Fill(ds);

// Is this changing (updating) data in DataSet is correct ???????????
ds->Tables->Item[0]->Rows->Item[0]->Item[1] = S"Jure";
ds->Tables->Item[0]->Rows->Item[0]->Item[2] = S"Smith";
// etc.

OleDbCommandBuilder* cb = new OleDbCommandBuilder(da);

DataSet* dsChanges = ds->GetChanges();

if (dsChanges != NULL)
{
da->Update(dsChanges);

ds->AcceptChanges();
}

This code works correct, but I’m not sure that this operation is regular:
ds->Tables->Item[0]->Rows->Item[0]->Item[1] = S"Jure";

Please, help me.
Thanks!

Andy Tacker
February 10th, 2005, 03:04 AM
Its ok

juresmith
February 16th, 2005, 06:34 AM
Thanks a lot!!!

bvhar
May 2nd, 2005, 02:48 AM
Hi,

You can do like this also.

You can create a DataRow object.

drwuser=myDataSet.Tables("AccountsTable").NewRow
drwuser("code")=code.text
drwuser("name")=name.text

myDataset.Tables("AccountsTable").Rows.Add(drwuser)


<snip>