By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,351 Members | 1,316 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,351 IT Pros & Developers. It's quick & easy.

VB6 recordset.update , field selective update (Beginers Q)

P: 3
I have a recordset "ADODC_path.recordset" which takes input from two tables
When the field values are put into the textboxes and then edited and updated back into the tables, using the following codes, everything works fine.

Expand|Select|Wrap|Line Numbers
  1. "select * from path,Station where path.StationCode=Station.StationCode and path.traincode=" & Text2.Text
Two tables Station(fields: StationCode and StationName) and
Path(fields: StationCode ,TrainCode ,RouteOrder)

The following code for table updation works well
Expand|Select|Wrap|Line Numbers
  1.    With Adodc_path.Recordset
  2.                 .AddNew
  3.                 .Fields("path.stationcode") = rs.Fields("stationCode")
  4.                 .Fields("TrainCode") = Text2.Text
  5.                 .Update  'this updates the recordset,tables etc.
  6.             End With
The above code only updates the path table,( and thats what is required). This code is put in (ADD )button

I need to put the .update command in another command button(save) so that the editing can be cancelled using CANCEL button.
There comes the problem:
When I issue the Adodc_path.Recordset.update command, it updates both tables.
How can I update a set of selected fields only (but all rows)in one table,even if multiple tables are given in adcmdText query.

Kindly help.

With regards
Feb 17 '07 #1
Share this Question
Share on Google+
4 Replies

P: 1,646
Hi. This works by letting go of the idea that you have to do everyting with one sql statement.
In your code you are doing only one of 3 things:
1. updating path table where stationcode equals something
2. updating station table where stationcode equals something
3. updating both tables where stationcode equals something

You can write a separate sql statement for each of these three scenarios and call the one you need as you need it.

You don't need a recordset object to update a table or tables. Just a well put together sql statement.
Feb 17 '07 #2

P: 3
Thank you

Kindly clarify

1) How to issue seperate SQL commands to recordset object. I know the update command in SQL but dont know how to execute them in VB6.
2)How can we do it without recordset object.

Feb 19 '07 #3

P: 1,646
Use the execute method of the connection object

con.Execute "sql update statement here"
Feb 19 '07 #4

P: 3
Thanks , it is working

Feb 21 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.