Is there anything wrong with my insert code?

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.
 
W

William F. Robertson, Jr.

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
 
K

Kevin Spencer

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top