Is there anything wrong with my insert code?

  • Thread starter Thread starter Mano kumar
  • Start date Start date
M

Mano kumar

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.OleDb.OleDbException:
Operation must use an updateable query.

Source Error:


Line 31: objCommand = New OleDbCommand("INSERT
INTO DailyUpdates(content) VALUES('HELLO')", objConn)
Line 32: objCommand.Connection.Open()
Line 33: objCommand.ExecuteReader()
Line 34: objCommand.Connection.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.EventArgs) Handles
btnInsert.Click
Dim objConn As New OleDbConnection
("PROVIDER=Microsoft.Jet.OLEDB.4.0; Data
source=C:\Projects\SomeProject\Data\dailydosedb.mdb")
Dim objCommand As OleDbCommand

objCommand = New OleDbCommand("INSERT INTO
DailyUpdates(content) VALUES('HELLO')", objConn)
objCommand.Connection.Open()
objCommand.ExecuteReader()
objCommand.Connection.Close()
End Sub



thanks for helping me out.. once again, thanks in advance.
 
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
 
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
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
Back
Top