473,545 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

3 New Member
Sir,
I have a recordset "ADODC_path.rec ordset" 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.Reco rdset.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
M.Manoj
Feb 17 '07 #1
4 8784
willakawill
1,646 Top Contributor
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
mmanojkumar
3 New Member
Hi,
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.

regards
M.Manoj
Feb 19 '07 #3
willakawill
1,646 Top Contributor
Use the execute method of the connection object

con.Execute "sql update statement here"
Feb 19 '07 #4
mmanojkumar
3 New Member
Hi,
Thanks , it is working

regards
M.Manoj
Feb 21 '07 #5

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

Similar topics

1
12042
by: John Baker | last post by:
HI: I have a drop down box on a form, which I am linking to a query on my client table, producing two fields client and clientID (the record ID). On a click on the appropriate record, I want to create a macro that will update a field in another table (setup) with the client ID number. My problem is that I cant find the right
5
3665
by: Koen | last post by:
Hi all, I am experimenting with DAO. I wrote this sub to update one specific field of one specific row in one specific table. Nothing wrong with the SQL statement, but when I execute this I get 'Invalid Operation'. ******************* code ************************* Sub UpdateObsStatusAfterStatusChange(intObsID As Integer, intNewValue As...
3
382
by: Johm | last post by:
Update filed with percentage In the table Products we have to update the field SalesPrice with 2 percents . We have to increase all the Sales Prices of our products with 2 percent.Our idea is to multiply the price with 1.2 for all the products. However, I get the message " Syntax error in update statement. Could someone help me ? I...
1
1605
by: Kelly Olsen | last post by:
I have created an automatic update field in my Vendor_Table that automatically updates the date in that field to respond to any changes made to the record. However, I would like to display this information on my Vendor_Form. I would like to display the information contained in that field pertaining to whichever record is shown without the...
1
4200
by: Andy Frank | last post by:
I have a tabular form that has a combo box on it that is reading from a database. When that combobox changes, I want it to lookup a database record to get a value and set the value into another text field on the same form and record. Everything works fine except for that the change event updates everything on the form not just the current...
15
5644
by: Sabine Oebbecke | last post by:
Hi there, Acc 97 SR2 I hope there is someone out there able to help me with my weird problem. I try to update a field in a table with continuous numbers. My problem is that the code that I run from a button in a form sometimes works, sometimes it does not. So, I press the button, and the table is update
1
1596
by: Scott Emick | last post by:
I have the following datatables which are related: Transaction TransactionId-Sequence Orders OrderDetails when I process a daTransaction.update(dtTransaction) daTransactionIdSequence.update(dtTransactionIdSequence)
2
19569
by: Brett | last post by:
My database has 2 tables: Table1 & Table2. If a field is not null on a record in table2, then the not null fields in table1 that correspond to the records in table1 needs to be updated to match the field in table2. What I have is a form that is linked to Table2. If the users want to change a field in the main database (table1), they fill the...
0
1738
by: mesut | last post by:
Hi there, I've a question. I would like to create a global update button to update all changed records gridview. e.g. A gridview contains 5 columns an 2 of the columns can be updated by the user. (other 3 are readonly) e.g. a column called Status is a dropdownlistbox the user can choose a status of the product and the other column called...
0
7502
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7434
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7791
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6026
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3491
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
744
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.