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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi line sql

Status
Not open for further replies.

emozley

Technical User
Jan 14, 2003
769
0
0
GB
Hi

I am trying to execute a IF NOT THEN...BEGIN....END statement stored in a string in VB.NET but am not having much luck. It says there is an error at "BEGIN":

Code:
strSQL = "IF NOT EXISTS(SELECT * FROM AppsCheck_Apps WHERE ApplicationName='" & InstalledPrograms(i).DisplayName & "' " _
                                 & "BEGIN " _
                                 & "INSERT INTO AppsCheck_Apps (ApplicationName) VALUES ('" & InstalledPrograms(i).DisplayName & "')" _
                                 & "END"

Any ideas?

Thanks!

Ed
 
Missing a closing paranthesis...

Code:
strSQL = "IF NOT EXISTS(SELECT * FROM AppsCheck_Apps WHERE ApplicationName='" & InstalledPrograms(i).DisplayName & "'[highlight #EF2929])[/highlight] " _
                                 & "BEGIN " _
                                 & "INSERT INTO AppsCheck_Apps (ApplicationName) VALUES ('" & InstalledPrograms(i).DisplayName & "')" _
                                 & "END"

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
C#.NET Programmer
 
As simple as that! Well spotted thank you.

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top