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. MS Access and multiple statements on the same connection

MS Access and multiple statements on the same connection

Scheduled Pinned Locked Moved Database
databasecsharpperformancehelpquestion
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
    SebbaP
    wrote on last edited by
    #1

    Hi, I've just started working with ADO.NET, through which I read from and update a MS Access data base. Now, what I want to do is to first update exactly one row in a data base, and then retrieve the updated row. Currently, this is performed in two steps. However, I want to reduce these two steps into one batch statement like this "UPDATE....; SELECT...." to increase performance. OleDbCommand.ExecuteReader() throws an exception saying "Characters found after end of SQL statement.". What does this mean? I have tried to google my way to an answer, but I get mixed messages and become more and more confused the more I read. Is it possible to batch several statements, and query them on the same connection using MS Access? This is where people seem to disagree. Also, I can't use a stored procedure (which would be ideal btw), because the SELECT-statement returns a value, and that's not possible with MS Access :|. Any help and/or suggestions would be much appreciated! Thanks

    W 1 Reply Last reply
    0
    • S SebbaP

      Hi, I've just started working with ADO.NET, through which I read from and update a MS Access data base. Now, what I want to do is to first update exactly one row in a data base, and then retrieve the updated row. Currently, this is performed in two steps. However, I want to reduce these two steps into one batch statement like this "UPDATE....; SELECT...." to increase performance. OleDbCommand.ExecuteReader() throws an exception saying "Characters found after end of SQL statement.". What does this mean? I have tried to google my way to an answer, but I get mixed messages and become more and more confused the more I read. Is it possible to batch several statements, and query them on the same connection using MS Access? This is where people seem to disagree. Also, I can't use a stored procedure (which would be ideal btw), because the SELECT-statement returns a value, and that's not possible with MS Access :|. Any help and/or suggestions would be much appreciated! Thanks

      W Offline
      W Offline
      WDI
      wrote on last edited by
      #2

      I have your problem too. So i had to execute each statement seperatly to work e.g to insert a row and get its ID : oleDbCommand = new OleDbCommand ( "insert into myTable ... " , oleDbConnection ); . . . add parameters oleDbCommand.ExecuteNonQuery(); oleDbCommand = new OleDbCommand ( "select @@IDENTITY" , oleDbConnection ); int retValue = Convert.ToInt16( oleDbCommand.ExecuteScalar() );

      S 1 Reply Last reply
      0
      • W WDI

        I have your problem too. So i had to execute each statement seperatly to work e.g to insert a row and get its ID : oleDbCommand = new OleDbCommand ( "insert into myTable ... " , oleDbConnection ); . . . add parameters oleDbCommand.ExecuteNonQuery(); oleDbCommand = new OleDbCommand ( "select @@IDENTITY" , oleDbConnection ); int retValue = Convert.ToInt16( oleDbCommand.ExecuteScalar() );

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

        I've just learned that Access can't handle batching of statements, whereas SQL Server (probably among others) does. In other words, another weekness of MS Access, which I'm terribly stuck with :sigh: Thank you for your comment anyway!

        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