Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Inserting from VB.NET to SQL Compact

Inserting from VB.NET to SQL Compact

Scheduled Pinned Locked Moved Visual Basic
databasehelpcsharpjson
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheComputerMan
    wrote on last edited by
    #1

    Not sure if this belongs here or the databases forum. Interesting little problem this one. I am creating a list (of string) of statements to be inserted into a database table in SQL Compact (v3.1) listParams.Add("INSERT INTO [SYS_tbl_SelectText] ([SQLTitle],[SQLStatement]) VALUES ('APPTHISTORY','SELECT SDD_tbl_Appointments.AppointmentDate AS [Appt Date], SDD_tbl_Appointments.AppointmentStart AS [Starts], SDD_tbl_Appointments.AppointmentEnd AS [Ends], (SDD_tbl_Employees.FirstName+' '+SDD_tbl_Employees.LastName) AS [With], SDD_tbl_Treatments.Description AS [Treatment], SDD_tbl_Appointments.FullyPaid AS [Paid], SDD_tbl_Appointments.ValueGross AS [Value], SDD_tbl_Appointments.GrossOutStanding AS [Value Outstanding], SDD_tbl_Appointments.GoodsOutstanding AS [Goods Outstanding] FROM SDD_tbl_Appointments INNER JOIN SDD_tbl_Employees ON SDD_tbl_Appointments.EmployeeID = SDD_tbl_Employees.EmployeeID INNER JOIN SDD_tbl_Treatments ON SDD_tbl_Appointments.TreatCode = SDD_tbl_Treatments.ID')") It goes into the list just fine, but when the contents of the list are executed, this particular one causes an error: There was an error parsing the query. [ Token line number = 1,Token line offset = 276,Token in error = +SDD_tbl_Employees.LastName) AS [With], SDD_tbl_Treatments.Description AS [Treatment], SDD_tbl_Appointments.FullyPaid AS [Paid], ] Any ideas how to resolve this? It seems it does not like the +' '+

    T 1 Reply Last reply
    0
    • T TheComputerMan

      Not sure if this belongs here or the databases forum. Interesting little problem this one. I am creating a list (of string) of statements to be inserted into a database table in SQL Compact (v3.1) listParams.Add("INSERT INTO [SYS_tbl_SelectText] ([SQLTitle],[SQLStatement]) VALUES ('APPTHISTORY','SELECT SDD_tbl_Appointments.AppointmentDate AS [Appt Date], SDD_tbl_Appointments.AppointmentStart AS [Starts], SDD_tbl_Appointments.AppointmentEnd AS [Ends], (SDD_tbl_Employees.FirstName+' '+SDD_tbl_Employees.LastName) AS [With], SDD_tbl_Treatments.Description AS [Treatment], SDD_tbl_Appointments.FullyPaid AS [Paid], SDD_tbl_Appointments.ValueGross AS [Value], SDD_tbl_Appointments.GrossOutStanding AS [Value Outstanding], SDD_tbl_Appointments.GoodsOutstanding AS [Goods Outstanding] FROM SDD_tbl_Appointments INNER JOIN SDD_tbl_Employees ON SDD_tbl_Appointments.EmployeeID = SDD_tbl_Employees.EmployeeID INNER JOIN SDD_tbl_Treatments ON SDD_tbl_Appointments.TreatCode = SDD_tbl_Treatments.ID')") It goes into the list just fine, but when the contents of the list are executed, this particular one causes an error: There was an error parsing the query. [ Token line number = 1,Token line offset = 276,Token in error = +SDD_tbl_Employees.LastName) AS [With], SDD_tbl_Treatments.Description AS [Treatment], SDD_tbl_Appointments.FullyPaid AS [Paid], ] Any ideas how to resolve this? It seems it does not like the +' '+

      T Offline
      T Offline
      The Man from U N C L E
      wrote on last edited by
      #2

      I don't know about SQL Compact, though I assume the syntax is standard T-SQL, but from looking at your code you have a select statement inside quotes. Starting from

      TheComputerMan wrote:

      'SELECT SDD_tbl_Appointments.AppointmentDate

      so the +' '+ will act as a terminator for that string. Try using + CHAR(13) + instead of +' '+.

      If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) www.JacksonSoft.co.uk

      T 1 Reply Last reply
      0
      • T The Man from U N C L E

        I don't know about SQL Compact, though I assume the syntax is standard T-SQL, but from looking at your code you have a select statement inside quotes. Starting from

        TheComputerMan wrote:

        'SELECT SDD_tbl_Appointments.AppointmentDate

        so the +' '+ will act as a terminator for that string. Try using + CHAR(13) + instead of +' '+.

        If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) www.JacksonSoft.co.uk

        T Offline
        T Offline
        TheComputerMan
        wrote on last edited by
        #3

        Hi, yes this is placing a statement text into a database table. There are many ' characters in the statements but I only get a problem when using the +. Incidentally the identical code in SQL Server 2005 (as opposed to Compact) does not cause a problem - this is where the SELECT statement is used in the same format as part of an execute to create a stored procedure. In this the +' '+ goes straight in with no problem, but I have not tried storing it I must admit, only executing it.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups