Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating Multiple Tables in Same DataSet

Status
Not open for further replies.

Becks25Not

Programmer
Jun 23, 2004
176
US
Hello All,

I get an error in the follwing code. I have several tables in the dataset. I am trying to update them to the database using the data adapter's update method. I am using command's I created because there are protected columns and I read the command builder is not good for when there auto-increment columns. Table 1 and Table 2's update and inserts work great. I get the error on updating table 3. It has to do with the update method ... it is trying to use the update method from table 2. If I set the text of the UpdateCommand to "", I get a not initialized error. Is there a way around this (or a better way to do this?)

Thanks!!
~Becca

Code:
Code:
'** Tbl1
	Me.daDb.UpdateCommand = Me._TableStructures.Tbl1UpdateCommand
	Me.daDb.UpdateCommand.Connection = Me.conDb
	Me.daDb.InsertCommand = Me._TableStructures.Tbl1InsertCommand
	Me.daDb.InsertCommand.Connection = Me.conDb
	Me.daDb.Update(Me.dt1)

'** Tbl2
	Me.daDb.UpdateCommand = Me._TableStructures.Tbl2UpdateCommand
	Me.daDb.UpdateCommand.Connection = Me.conDb
	Me.daDb.InsertCommand = Me._TableStructures.Tbl2InsertCommand
	Me.daDb.InsertCommand.Connection = Me.conDb
	Me.daDb.Update(Me.dt2)

'** Tbl3
	Me.daDb.InsertCommand = Me._TableStructures.Tbl3InsertCommand
	Me.daDb.InsertCommand.Connection = Me.conDb
[COLOR=red]	Me.daDb.Update(Me.dt3)		'FAILS HERE W/ aforementioned exceptions [/color]

	Me.dsDb.AcceptChanges()
 
Try creating an actual UpdateCommand for Table3.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Hi jebnson,

Thanks for reponding.

I did that just to keep moving along but it's kind of bogus / extra, unnecessary work b/c updates aren't allowed and I don't expose a way for the user to modify data, only add.

Thanks!
~Becca
 
Well, it seems that the DataAdapter "thinks" that an update is occurring, and so is trying to use the UpdateCommand.

If what you are doing permits, maybe try the Table3 update first and see what happens.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top