Link to home
Create AccountLog in
Avatar of H-SC
H-SCFlag for United States of America

asked on

Error Parsing Query

I have a local database(SQL CE) in my winforms application that I am trying to update with the following code.  When the code runs it errors out.

Here is the Error - There was an error parsing the query. [ Token line number = 1,Token line offset = 109,Token in error = ) ]

Here is my code:
Dim myConn2 As SqlServerCe.SqlCeConnection = New SqlServerCe.SqlCeConnection("DataSource=|DataDirectory|\SSI.sdf")
        Try
        Catch ex As Exception
        End Try
        myConn2.Open()
        Dim command2 As New SqlServerCe.SqlCeCommand("insert into insp_def_buildings(internalctl)select ctl_num from buildings_rooms where buildings_rooms.sel = 1)", myConn2)
        command2.ExecuteNonQuery()
        command2.Dispose()
        myConn2.Dispose()
Avatar of philipjonathan
philipjonathan
Flag of New Zealand image

I think it's due to the lack of space between "(internalctl)" and "select" in your SQL statement:
"insert into insp_def_buildings(internalctl) select ctl_num from buildings_rooms where buildings_rooms.sel = 1)"
Avatar of H-SC

ASKER

philipjonathan,

many thanks....I just tried that and I still keep getting that same error.  I have started developing this application and am using compact edition for the sync advantages, however if I can't run standard sql against CE then it is a show stopper for me, I can't seem to figure this one out.  I have read that nested selects and CE do not work well together.  This may be a case of just that and I will have to look for another route to take to get the sync capabilities that I am needing for this particular project.
ASKER CERTIFIED SOLUTION
Avatar of philipjonathan
philipjonathan
Flag of New Zealand image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of H-SC

ASKER

philipjonathan,

Thats it!
Your suggestions did it.  Here is what I ended up with

 ("insert into insp_def_buildings(internalctl) select ctl_num from buildings_rooms where buildings_rooms.sel = 1", myConn2)

many thanks for your help on this problem.
Well, actually I just give you another pair of eyes to look at the SQL queries. SQL queries are always prone to syntax error because it's not checked in compile time. Glad that you made it :)