Problems with INSERT to a simple Access database!
Hello!I got a simple Access database with a table called Baskets. That table got 4 columns (id(counter), prodid(int), count(int), sessionid(int)).
I can connect to this database and do SELECT queries without any problems but when I try to do a INSERT I get an error. Below is the errormessage in Swedish:
Feltyp:
Microsoft JET Database Engine (0x80004005)
Operationen måste använda en fråga som kan uppdateras.
/webbshop/add.asp, line 23
If I translate this into english it says "The operation needs to use a question that can be updated."
The code at line 28 looks like this:
myDatabaseConnection.Execute "INSERT INTO Baskets VALUES(" & prodid & "," & count & "," & sessionid & ")"
I can not understand why I can't do a insert. Does the counter at the first column the question to crash??
The code in total looks like this:
<%
' Response.Status = "204 No Content"
' Vi läser in värden
sessionid = Session.Sessionid
count = Request.Form("Antal")
prodid = Request.Form("ProdId")
'Vi skapar databaskopplingen
Set myDatabaseConnection = Server.CreateObject("ADODB.Connection")
'Vi skapar den virituella sökvägen till databasfilen
databasePath = "Databas/myshop.mdb"
'Vi skapar en sträng med alla parametrar för databasen
connectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="
connectionString = connectionString & server.mappath(databasePath) & ";"
'Vi öppnar kopplingen till databasen
myDatabaseConnection.Open connectionString
'Vi ställer frågan
myDatabaseConnection.Execute "INSERT INTO Baskets VALUES(" & prodid & "," & count & "," & sessionid & ")"
'Vi stänger alla databasobjekt
myDatabaseConnection.Close
Set myDatbaseConnection = Nothing
%>
Please help me out!
Best regards
Fredrik Andersson
