?
Solved

SQL in VB ...

Posted on 2003-03-16
6
Medium Priority
?
178 Views
Last Modified: 2010-05-01
if i have 2 tables , tabel1 and table2 , how can i insert the value into table1-ID and table2-CustomerID ?

*ID is the field in table1 and CustomerID in table2 ?

-----------------------------------------------------------------------------------

sSQL1 = "insert into account_table(ACC_TYPE )values ('" & lblAccType & "') where account_table.CUST_ID = customerinfo_table.ID"
Set rs = conn.Execute(sSQL1)

is there anything wrong with above code ?

I'm running mySQL in VB :)

THanks . Marks will be awarded base on First Come First Serve Basis.
0
Comment
Question by:ANGWK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 11

Expert Comment

by:rdrunner
ID: 8147052
The where clause is not clear...

You dont know which ID you are talking about. If you want to update existing data you should use an update script...

If you want to insert new data you should pass the ID along and insert both values (type & ID)
0
 

Author Comment

by:ANGWK
ID: 8147106
rdrunner , how bout if i wan to enter a value into 2 different tables , different fields ?>
0
 

Author Comment

by:ANGWK
ID: 8147126
rdrunner , how bout if i wan to enter a value into 2 different tables , different fields ?>
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 11

Expert Comment

by:rdrunner
ID: 8147150
Then use 2 insert statements (can be in one string seperated by go), or use a trigger or a stored procedure...

And your SQL also only tries to insert one row into one table...

0
 

Author Comment

by:ANGWK
ID: 8147698
rdrunner , how bout if i wan to enter a value into 2 different tables , different fields ?>
0
 
LVL 11

Accepted Solution

by:
rdrunner earned 60 total points
ID: 8147749
an INSERT only has ONE target

-> 2 Target tabels -> 2 Inserts
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question