Inserting row in database
I have some problems using ExecuteNonQuery. I receive an error saying "Operation must an updatetable query". I have changed the Folder options to
Tools | Folder Options | View and uncheck "Use Simple File Sharing (Recommended)" at the bottom.
I can't make it work, here's my code.
Code:
sub insertKunde(sender as object, e as eventArgs)
'Her bruger jeg direkte SQL-kommandoer til at indsætte i databasen
Dim objConnection as OleDbConnection
Dim objCommand as OleDbCommand
Dim strSql as string
Dim strCn as String ="Provider=Microsoft.jet.oledb.4.0;"
strCn += "Data Source=" & server.mappath("autohuset.MDB") & ";"
'Her åbner jeg en connection
objConnection = New OleDbConnection(strCn)
objConnection.open()
strSql = "INSERT INTO kunde ('kundenr','navn','adresse','postnr','telefonnr','e-mail' )" & _
" VALUES ('12','Hans Peter','Ny vej 12','9000','99661565','[email protected]' )"
objCommand = New OleDbCommand(strSql, objConnection)
objCommand.ExecuteNonQuery()
end sub