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. Database & SysAdmin
  3. Database
  4. Build Errors on SQL Statement

Build Errors on SQL Statement

Scheduled Pinned Locked Moved Database
databasehelp
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.
  • S Offline
    S Offline
    Swisher24
    wrote on last edited by
    #1

    First Off, I'm new to code project so if I post something thats already posted sorry. But I'm hoping to find someone who can help out with this build error that I'm receiving on an oledbadapter.insertcommand. I'm loading data into a datagrid for review. After reviewing the data I'm using a sub procedure to load the data into the database from the datagrid. "oledbadapter.InsertCommand(Insert Into table1 from )" error(s): (249): Comma, ')', or a valid expression continuation expected. (249): Property access must assign to the property or use its value. I'm having problems figuring out what to put after the "from" statement. If this is not enough information just let me know and also let me know if I'm posting this right with out being irate about it.

    Swish

    C 1 Reply Last reply
    0
    • S Swisher24

      First Off, I'm new to code project so if I post something thats already posted sorry. But I'm hoping to find someone who can help out with this build error that I'm receiving on an oledbadapter.insertcommand. I'm loading data into a datagrid for review. After reviewing the data I'm using a sub procedure to load the data into the database from the datagrid. "oledbadapter.InsertCommand(Insert Into table1 from )" error(s): (249): Comma, ')', or a valid expression continuation expected. (249): Property access must assign to the property or use its value. I'm having problems figuring out what to put after the "from" statement. If this is not enough information just let me know and also let me know if I'm posting this right with out being irate about it.

      Swish

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Second attempt at this as my connection broke the first time round and IE lost the post.

      Swisher24 wrote:

      "oledbadapter.InsertCommand(Insert Into table1 from )" error(s): (249): Comma, ')', or a valid expression continuation expected. (249): Property access must assign to the property or use its value.

      Okay. The OleDbDataAdapter class doesn't have a method called InsertCommand (see the class reference on MSDN[^]). It does, however, have a property called InsertCommand so your code should read something like this:

      oledbadapter.InsertCommand = someSqlString

      Swisher24 wrote:

      I'm having problems figuring out what to put after the "from" statement

      Okay, this second part is that you are using an INSERT command. You get data "from" a table, you put data "into" a table. You have already specified which table you are putting data "into". See the INSERT Command reference[^] on MSDN. Your command needs to be something along the lines of:

      INSERT INTO Table1(Column1, Column2, Column3) VALUES ('value1', 'value2', 'value3')

      So, you need to specify the columns that the data will be going into and the values of the data. I've not used Data Adapters much (they don't fit most of the applications I've written) so I'm going on 3 year old knowledge that you typically specify the values as a series of parameters. If your database is SQL Server the parameter name is in the format @paramName, if you are using Access the parameters are a simple ? placeholder (so remember that the order of the columns must match the order of the columns in the DataTable being passed into the adapter) Does this help?


      Upcoming Scottish Developers events: *

      S 1 Reply Last reply
      0
      • C Colin Angus Mackay

        Second attempt at this as my connection broke the first time round and IE lost the post.

        Swisher24 wrote:

        "oledbadapter.InsertCommand(Insert Into table1 from )" error(s): (249): Comma, ')', or a valid expression continuation expected. (249): Property access must assign to the property or use its value.

        Okay. The OleDbDataAdapter class doesn't have a method called InsertCommand (see the class reference on MSDN[^]). It does, however, have a property called InsertCommand so your code should read something like this:

        oledbadapter.InsertCommand = someSqlString

        Swisher24 wrote:

        I'm having problems figuring out what to put after the "from" statement

        Okay, this second part is that you are using an INSERT command. You get data "from" a table, you put data "into" a table. You have already specified which table you are putting data "into". See the INSERT Command reference[^] on MSDN. Your command needs to be something along the lines of:

        INSERT INTO Table1(Column1, Column2, Column3) VALUES ('value1', 'value2', 'value3')

        So, you need to specify the columns that the data will be going into and the values of the data. I've not used Data Adapters much (they don't fit most of the applications I've written) so I'm going on 3 year old knowledge that you typically specify the values as a series of parameters. If your database is SQL Server the parameter name is in the format @paramName, if you are using Access the parameters are a simple ? placeholder (so remember that the order of the columns must match the order of the columns in the DataTable being passed into the adapter) Does this help?


        Upcoming Scottish Developers events: *

        S Offline
        S Offline
        Swisher24
        wrote on last edited by
        #3

        Thanks Colin but I've figured out another way to take the data from the datagrid into the database.

        Swish

        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