Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

SQL in VB ...

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
ANGWK
Asked:
ANGWK
  • 3
  • 3
1 Solution
 
rdrunnerCommented:
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
 
ANGWKAuthor Commented:
rdrunner , how bout if i wan to enter a value into 2 different tables , different fields ?>
0
 
ANGWKAuthor Commented:
rdrunner , how bout if i wan to enter a value into 2 different tables , different fields ?>
0
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!

 
rdrunnerCommented:
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
 
ANGWKAuthor Commented:
rdrunner , how bout if i wan to enter a value into 2 different tables , different fields ?>
0
 
rdrunnerCommented:
an INSERT only has ONE target

-> 2 Target tabels -> 2 Inserts
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now