Is there anything wrong with my insert code?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mano kumar

    #1

    Is there anything wrong with my insert code?

    hello guys, i'm having a very strange problem, this is a
    simple insert code. andthe insert stmt has NO problem cos
    i've tried it on my access table.

    and heres the error msg

    Operation must use an updateable query.
    Description: An unhandled exception occurred during the
    execution of the current web request. Please review the
    stack trace for more information about the error and where
    it originated in the code.

    Exception Details: System.Data.Ole Db.OleDbExcepti on:
    Operation must use an updateable query.

    Source Error:


    Line 31: objCommand = New OleDbCommand("I NSERT
    INTO DailyUpdates(co ntent) VALUES('HELLO') ", objConn)
    Line 32: objCommand.Conn ection.Open()
    Line 33: objCommand.Exec uteReader()
    Line 34: objCommand.Conn ection.Close()
    Line 35: End Sub





    BELOW HERE IS THE CODE WHICH I USE...

    Private Sub btnInsert_Click (ByVal sender As
    System.Object, ByVal e As System.EventArg s) Handles
    btnInsert.Click
    Dim objConn As New OleDbConnection
    ("PROVIDER=Micr osoft.Jet.OLEDB .4.0; Data
    source=C:\Proje cts\SomeProject \Data\dailydose db.mdb")
    Dim objCommand As OleDbCommand

    objCommand = New OleDbCommand("I NSERT INTO
    DailyUpdates(co ntent) VALUES('HELLO') ", objConn)
    objCommand.Conn ection.Open()
    objCommand.Exec uteReader()
    objCommand.Conn ection.Close()
    End Sub



    thanks for helping me out.. once again, thanks in advance.
  • William F. Robertson, Jr.

    #2
    Re: Is there anything wrong with my insert code?

    I don't know if you can use ExecuteReader for inserts. You might want to
    look at the ExecuteNonQuery method to do your inserts.

    HTH,

    bill

    "Mano kumar" <manokumar76@ho tmail.com> wrote in message
    news:0a0f01c394 aa$0aa236a0$a40 1280a@phx.gbl.. .[color=blue]
    > hello guys, i'm having a very strange problem, this is a
    > simple insert code. andthe insert stmt has NO problem cos
    > i've tried it on my access table.
    >
    > and heres the error msg
    >
    > Operation must use an updateable query.
    > Description: An unhandled exception occurred during the
    > execution of the current web request. Please review the
    > stack trace for more information about the error and where
    > it originated in the code.
    >
    > Exception Details: System.Data.Ole Db.OleDbExcepti on:
    > Operation must use an updateable query.
    >
    > Source Error:
    >
    >
    > Line 31: objCommand = New OleDbCommand("I NSERT
    > INTO DailyUpdates(co ntent) VALUES('HELLO') ", objConn)
    > Line 32: objCommand.Conn ection.Open()
    > Line 33: objCommand.Exec uteReader()
    > Line 34: objCommand.Conn ection.Close()
    > Line 35: End Sub
    >
    >
    >
    >
    >
    > BELOW HERE IS THE CODE WHICH I USE...
    >
    > Private Sub btnInsert_Click (ByVal sender As
    > System.Object, ByVal e As System.EventArg s) Handles
    > btnInsert.Click
    > Dim objConn As New OleDbConnection
    > ("PROVIDER=Micr osoft.Jet.OLEDB .4.0; Data
    > source=C:\Proje cts\SomeProject \Data\dailydose db.mdb")
    > Dim objCommand As OleDbCommand
    >
    > objCommand = New OleDbCommand("I NSERT INTO
    > DailyUpdates(co ntent) VALUES('HELLO') ", objConn)
    > objCommand.Conn ection.Open()
    > objCommand.Exec uteReader()
    > objCommand.Conn ection.Close()
    > End Sub
    >
    >
    >
    > thanks for helping me out.. once again, thanks in advance.[/color]


    Comment

    • Kevin Spencer

      #3
      Re: Is there anything wrong with my insert code?

      Looks to me like you're using an Access database, and it is in a folder that
      doesn't have "Modify" file system permission for the user account under
      which your ASP.Net app is running.

      --
      HTH,

      Kevin Spencer
      Microsoft MVP
      ..Net Developer
      All hotels in Benidorm. The best selection of Benidorm hotels with reviews and maps. Book in advance and save.

      Big Things are made up of
      Lots of Little Things.

      "Mano kumar" <manokumar76@ho tmail.com> wrote in message
      news:0a0f01c394 aa$0aa236a0$a40 1280a@phx.gbl.. .[color=blue]
      > hello guys, i'm having a very strange problem, this is a
      > simple insert code. andthe insert stmt has NO problem cos
      > i've tried it on my access table.
      >
      > and heres the error msg
      >
      > Operation must use an updateable query.
      > Description: An unhandled exception occurred during the
      > execution of the current web request. Please review the
      > stack trace for more information about the error and where
      > it originated in the code.
      >
      > Exception Details: System.Data.Ole Db.OleDbExcepti on:
      > Operation must use an updateable query.
      >
      > Source Error:
      >
      >
      > Line 31: objCommand = New OleDbCommand("I NSERT
      > INTO DailyUpdates(co ntent) VALUES('HELLO') ", objConn)
      > Line 32: objCommand.Conn ection.Open()
      > Line 33: objCommand.Exec uteReader()
      > Line 34: objCommand.Conn ection.Close()
      > Line 35: End Sub
      >
      >
      >
      >
      >
      > BELOW HERE IS THE CODE WHICH I USE...
      >
      > Private Sub btnInsert_Click (ByVal sender As
      > System.Object, ByVal e As System.EventArg s) Handles
      > btnInsert.Click
      > Dim objConn As New OleDbConnection
      > ("PROVIDER=Micr osoft.Jet.OLEDB .4.0; Data
      > source=C:\Proje cts\SomeProject \Data\dailydose db.mdb")
      > Dim objCommand As OleDbCommand
      >
      > objCommand = New OleDbCommand("I NSERT INTO
      > DailyUpdates(co ntent) VALUES('HELLO') ", objConn)
      > objCommand.Conn ection.Open()
      > objCommand.Exec uteReader()
      > objCommand.Conn ection.Close()
      > End Sub
      >
      >
      >
      > thanks for helping me out.. once again, thanks in advance.[/color]


      Comment

      Working...