borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (MYSQL query)Next Topic (help! datagrid problem.) New Topic New Poll Post Reply
AndreaVB Forum : Database : ADO.net sqlcommandbuilder Update/Insert/Delete Logic
Poster Message
Nick2k3
Level: Big Cheese

Registered: 23-11-2003
Posts: 23

icon ADO.net sqlcommandbuilder Update/Insert/Delete Logic

i have a problem with datatables.

Lets say i have a table containg two fields that are both primary keys,

I then connect to the table using the usual ado net connection process.
connection->sqlcommand->sqladapter->sqlcommandbuilder(using the sqlcommand)->datatable

Then afterwards, i binded it to the Datagridview. I inserted two rows on the datagridview:

Field1            Field2
Value1          Value1Desc
Value2          Value2Desc

I saved it using the sqladapter.update(datatable) command and worked okay.

Next I Deleted the second row:
Field1            Field2
Value1          Value1Desc
Value2          Value2Desc (delete)

Next I Inserted a new row with the same values as the previously deleted row.

Field1            Field2
Value1          Value1Desc
Value2          Value2Desc (New Row Inserted)

then i called the sqladapter.update(datatable)  command. what happens next? errrorrrr!!!!!

if anyone knows how to go about the incoming error please tell me how to fix it.

And also can i change the way the update,insert,delete logic is performed on the command builder? lets say i want delete first then update and finally insert?


____________________________
Error 404 ...File not found...!!!!

17-09-2006 at 11:26 AM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: ADO.net sqlcommandbuilder Update/Insert/Delete Logic

Hi,
The error is probably because your cached recordset is inconsistent with the database. Run the update command after the delete to synchronize the recordsets, then run the insert for the new record.


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

17-09-2006 at 12:06 PM
View Profile Send Email to User Show All Posts | Quote Reply
Nick2k3
Level: Big Cheese

Registered: 23-11-2003
Posts: 23
icon Re: ADO.net sqlcommandbuilder Update/Insert/Delete Logic

quote:
GeoffS wrote:
Hi,
The error is probably because your cached recordset is inconsistent with the database. Run the update command after the delete to synchronize the recordsets, then run the insert for the new record.



actually i was thinking about that earlier that is why i wrote something like :

"And also can i change the way the update,insert,delete logic is performed on the command builder? lets say i want delete first then update and finally insert?"

If you have any sample code to change how the update, insert,delete is to be performed please post it. (i'm using a commandbuilder)

____________________________
Error 404 ...File not found...!!!!
17-09-2006 at 06:54 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : ADO.net sqlcommandbuilder Update/Insert/Delete Logic
Previous Topic (MYSQL query)Next Topic (help! datagrid problem.) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder