|
-
February 10th, 2005, 03:50 AM
#1
Changing data in DataSet
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!
-
February 10th, 2005, 04:04 AM
#2
Re: Changing data in DataSet
If you think you CAN, you can, If you think you CAN'T, you are probably right.
Have some nice Idea to share? Write an Article Online or Email to us and You may WIN a Technical Book from CG.
-
February 16th, 2005, 07:34 AM
#3
Re: Changing data in DataSet
-
May 2nd, 2005, 02:48 AM
#4
Re: Changing data in DataSet
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>
Last edited by Brad Jones; May 3rd, 2005 at 08:26 AM.
Reason: Removed SPAM / Advertising portion of post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|