using SQL stmt

josh2009

Member
Joined
Sep 16, 2009
Messages
14
Programming Experience
Beginner
Trying to run the ff SQL stmt in a VB script and assign to a variable -

ssql = "SELECT Interventional From SS_Selection_Set_Elements_BLGH Where SS_Selection_Set_Elements_BLGH.element_text = """ & currentCathProceduresRecord("Procedure_Name")

I get the ff exception error -

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ApplicationException: Failed to execute sql statement: 'SELECT Interventional From SS_Selection_Set_Elements_BLGH Where SS_Selection_Set_Elements_BLGH.element_text = "Coronary Angiography' ---> System.Data.SqlClient.SqlException: Unclosed quotation mark after the character string 'Coronary Angiography'.
Incorrect syntax near 'Coronary Angiography'.
at System.Data.SqlClient.SqlConne

Notice that it tried to enclose the procedure name Coronary Angiography in quotes but was only able to add the open quote marks but not the end quote marks. Even when I added two sets of quote marks within the SQL statement, it did not recognize the second set of quote marks.

Any help will be greatly appreciated. Thanks
 
I think this will fix it:

VB.NET:
ssql = "SELECT Interventional From SS_Selection_Set_Elements_BLGH Where SS_Selection_Set_Elements_BLGH.element_text = '" & currentCathProceduresRecord("Procedure_Name") & "'"

:)
 
Back
Top