Help with nested sql statements

Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
Reply

Join Date: Jun 2007
Posts: 49
Reputation: Mr.Wobbles is an unknown quantity at this point 
Solved Threads: 2
Mr.Wobbles Mr.Wobbles is offline Offline
Light Poster

Help with nested sql statements

 
0
  #1
Feb 13th, 2008
First I will show you my sql, just in case it is some obvious syntax error on my part:

  1. "INSERT INTO tblResults(status, enthusiasm, communication, knowledge, interaction,
  2. organization, responsiveness, instID, comment)" & _
  3. "VALUES(""" & status & """, """ & enthusiasmB & """, """ & communicationB & """, """ & _
  4. knowledgeB & """, """ & interactionB & """, """ & organizationB & """, """ & _
  5. responsivenessB & """, (" & getFacIDB & "), """ & _
  6. comment & """)"

where

  1. Dim getFacIDB As String = "SELECT instID FROM tblInstructor" & _
  2. " WHERE firstName = '" & firstNameB & "'"

So if you can't tell what I am trying to do is pull the id from another table so that I have a valid faculty reference between the tables. What I am looking for is a Select statement nested inside an Insert statement.

The error I am getting is "Unspecified error" on:
dr = resultsCommandA.ExecuteNonQuery

Any help is appreciated.
Mr.Wobbles~
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 49
Reputation: Mr.Wobbles is an unknown quantity at this point 
Solved Threads: 2
Mr.Wobbles Mr.Wobbles is offline Offline
Light Poster

Re: Help with nested sql statements

 
0
  #2
Feb 13th, 2008
Instead of nesting the queries I pulled them apart and set the Select statement to a variable and then called my sql for the insert statement. If anyone has any better ideas just let me know I am open to suggestions.
Mr.Wobbles~
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC