Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL statement not passing from vb

Status
Not open for further replies.

DebbieCoates

Programmer
Oct 2, 2007
23
0
0
GB
i have a SQL statement that i am passing via VB, but for some reason I am getting an error saying that there is a missing operator in string, and yet when i run the statement I am trying to pass in the sql query analyser, it works perfect, has anyone any idea's why?

Dim sSQL As String

sSQL = "SELECT T_Funder.EnquiryID, T_Funder.FunderTypeID, T_Funder.FundSourceID, FunderTypes.FunderType, FundSources.name"
sSQL = sSQL & " FROM T_Funder LEFT OUTER JOIN"
sSQL = sSQL & " FunderTypes ON T_Funder.FunderTypeID = FunderTypes.FunderTypeID LEFT OUTER JOIN"
sSQL = sSQL & " FundSources ON T_Funder.FundSourceID = FundSources.fundsourceid WHERE (T_Funder.EnquiryID = '" & gEnquiryID & "')"

Debug.Print sSQL
 
What is the data type of the T_Funder.EnquiryID database item and what is the value of gEnquiryID? What happens if you remove single quotes you are wrapping around T_Funder.EnquiryID?

Not sure why it would work in Query Analyser but not VB but one step at a time...
 
Also can you post the line that generates the error? It may be nothing to do with the SQL query but the syntax of the VB line.
 
Also, check the err.source property. If it isn't VB (I suspect it isn't), check the ADO Errors collection. The problem could be somewhere in the ADO connection.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top