SunQuest
 
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
IBM developerWorks
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old August 9th, 2004, 12:49 PM
Kristin Kristin is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 56 Kristin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
FOR EACH statement trouble!!??

Not sure if I am even on the right track.... I am using an SQL 2000 database. I need to update/compare two tables and I'm looking for a logical way to do it....

I need to check all records in one table to see if the text in one particular column is equal to the text in another column in a seperate table.... and if so, perform an update query.

OK, this is confusing I know. I have a table "chains", FOR EACH record in chains, I need to take the field "speciminid" and see if it matches the field "speciminid" in my other table "records"

And if speciminid in chains = speciminid in records, set chainpath = the chainnum(automatic integer) for that particular record in chains!

I think I am way off, but I set up a form, linked with an ADODC control to my table chains. then I have a command that executed this...

Private Sub Command1_Click()
Dim chains As Collection
Dim chainnum As Variant
Dim speciminid As Variant
For Each chainnum In chains
DataEnvironment1.AutoUpdateRecords chainnum, speciminid 'this is the update query to enter the chainnum into the records table if Speciminid in chains = speciminid in records....
Set DataEnvironment1 = Nothing
Next
End Sub

can anyone help? I suck at coding.

thanks for any input or suggestions anyone might have!

Kristin

Reply With Quote
  #2  
Old August 10th, 2004, 03:54 AM
Mythomep Mythomep is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Zaandam, The Netherlands
Posts: 70 Mythomep User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 37 sec
Reputation Power: 4
Send a message via MSN to Mythomep
Hi,

If I may ask, why go through so much trouble writing a complete script to do something that the DBMS (SQL2000) can do just as easily with a single statement? Let me explain. If I understand you correctly, you have two tables with a related field (speciminid). The speciminid is a one on one relation with both chains and records.

Now, you can make use of this relation by issueing the following update statement on the database:

UPDATE Chains
SET chains.chainpath = o.chainnum
FROM Records a, chains o
WHERE a.speciminid = o.speciminid


This will update every chains record with the chainnum from the record that contains the exact speciminid. This will execute nice and fast. If you make it a stored procedure in the database, you can make it even more faster. Now, if I didn't understand your problem at hand, please give an example of the data (1 or 2 records) and I'll look into it. Any questions, please ask.

Grtz.©

M.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > FOR EACH statement trouble!!??


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway