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!
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!