DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   VB.NET (http://www.daniweb.com/forums/forum58.html)
-   -   Help with nested sql statements (http://www.daniweb.com/forums/thread109012.html)

Mr.Wobbles Feb 13th, 2008 3:54 pm
Help with nested sql statements
 
First I will show you my sql, just in case it is some obvious syntax error on my part:

"INSERT INTO tblResults(status, enthusiasm, communication, knowledge, interaction,
                                  organization, responsiveness, instID, comment)" & _
 "VALUES(""" & status & """, """ & enthusiasmB & """, """ & communicationB & """, """ & _
                    knowledgeB & """, """ & interactionB & """, """ & organizationB & """, """ & _
                    responsivenessB & """, (" & getFacIDB & "), """ & _
                    comment & """)"

where

Dim getFacIDB As String = "SELECT instID FROM tblInstructor" & _
                                " 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 Feb 13th, 2008 4:39 pm
Re: Help with nested sql statements
 
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.


All times are GMT -4. The time now is 8:43 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC