...

View Full Version : adding record to access problems



carol
10-12-2003, 05:55 AM
I was wondering if anyone could help me with advice on this problem. I keep on looking at it and just can't see where the error is coming from or what it is trying to tell me

I am using a access database and am getting this error when i am trying to add a record to this database

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.

The conection file i am using is:

<% dim DRV, DBQ, CS , oC , oRS, oRS1, oCM
DRV = "Driver={Microsoft Access Driver (*.mdb)}; "
DBQ = "DBQ= C:\GWIT\product.mdb; "
CS = DRV & DBQ
set oC = server.createobject("ADODB.connection")
set oCM = server.createobject("ADODB.Command")
%>

and the code i am using to add a new record is as below the error is stating it is at this part of the code oCM.Execute sql

Dim sql
sql = "INSERT INTO tblCustomer"
sql = sql & "(CustFName, CustLName, CustState ,CustCountry ,CustEmail, CustRSize, CustRNum ,CustAdult, CustChild, CustCheckIn, CustCheckOut, CustHighFloor, CustBaby, CustFoldbed, CustPrice)"
sql=sql & " VALUES "
sql=sql & "('" & session.contents("name") & "',"
sql=sql & "'" & session.contents("Lname") & "',"
sql=sql & "'" & session.contents("state") & "',"
sql=sql & "'" & session.contents("country") & "',"
sql=sql & "'" & session.contents("email") & "',"
sql=sql & "'" & session.contents("roomsize") & "',"
sql=sql & "'" & session.contents("roomnum") & "',"
sql=sql & "'" & session.Contents("adult") & "',"
sql=sql & "'" & session.Contents("child") & "',"
sql=sql & "'" & session.Contents("checkIn") & "',"
sql=sql & "'" & session.Contents("checkOut") & "',"
sql=sql & "'" & session.Contents("highfloor") & "',"
sql=sql & "'" & session.Contents("baby") & "',"
sql=sql & "'" & session.Contents("foldbed") & "',"
sql=sql & "'" & session.Contents("price") & "')"


oC.open CS
oCM.ActiveConnection = oC
oCM.CommandText = sql
oCM.Execute sql
%>

Any help would be appreciated as i am really stumped
Thanks

raf
10-12-2003, 09:05 AM
Did you check that the file is not read only and that it's located in a directory where you have write rights on ?

carol
10-12-2003, 09:34 AM
I Have checked the file isn't read only and the yes the file path is correct and i definally have write rights on this file.

raf
10-12-2003, 10:06 AM
Well, if you are sure it's not a permission issue, then check this thread.

http://www.codingforums.com/showthread.php?s=&threadid=16033&highlight=operation

I've gotten the same error after copying the mdb files from one machine to another. Maybe try the fix i explain there (copy it to another name, remove original db and rename the copy to the original filename)

carol
10-12-2003, 10:31 AM
Okay did that copied the db and removed the original one then renamed the copy

I managed to get rid of that error but i now have this error

Which i know when you are working locally means you are trying to use your asp page when you have your access database open
but that isn't the case this time

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0xa28 Thread 0xd30 DBC 0x14e2434 Jet'.


Thanks for all you help so far it is much appreciated

raf
10-12-2003, 11:19 AM
It's better to use a virtual and relative path, instead of a real path.

Try using a connectionstring like


dim conn
set conn=server.CreateObject("adodb.connection")
conn.Open("provider=microsoft.jet.oledb.4.0;data source="& Request.ServerVariables("APPL_PHYSICAL_PATH") & "GWIT/product.mdb")

the "GWIT/product.mdb" is the path from the applications root.

I never had that error, and i don't see why you should get an error if your access db is opn. You can have more then 1 simultanious user for access so ...

carol
10-12-2003, 11:36 AM
i am really have lousy luck today

okay i have got this error now

ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another

I am starting to wonder if this is just one of those xp kinks that come with asp

I might try it on a different system and see if that helps

raf
10-12-2003, 01:45 PM
On what line is the error ?
It's not an XP problem.

Also, if you used the connectionstring i posted, you don't need the

oC.open CS
oCM.ActiveConnection = oC

Like


dim conn, sql, numinserted
set conn=server.CreateObject("adodb.connection")
conn.Open("provider=microsoft.jet.oledb.4.0;data source="& Request.ServerVariables("APPL_PHYSICAL_PATH") & "GWIT/product.mdb")

sql = "INSERT INTO tblCustomer"
sql = sql & "(CustFName, CustLName, CustState ,CustCountry ,CustEmail, CustRSize, CustRNum ,CustAdult, CustChild, CustCheckIn, CustCheckOut, CustHighFloor, CustBaby, CustFoldbed, CustPrice)"
sql=sql & " VALUES "
sql=sql & "('" & session.contents("name") & "',"
sql=sql & "'" & session.contents("Lname") & "',"
sql=sql & "'" & session.contents("state") & "',"
sql=sql & "'" & session.contents("country") & "',"
sql=sql & "'" & session.contents("email") & "',"
sql=sql & "'" & session.contents("roomsize") & "',"
sql=sql & "'" & session.contents("roomnum") & "',"
sql=sql & "'" & session.Contents("adult") & "',"
sql=sql & "'" & session.Contents("child") & "',"
sql=sql & "'" & session.Contents("checkIn") & "',"
sql=sql & "'" & session.Contents("checkOut") & "',"
sql=sql & "'" & session.Contents("highfloor") & "',"
sql=sql & "'" & session.Contents("baby") & "',"
sql=sql & "'" & session.Contents("foldbed") & "',"
sql=sql & "'" & session.Contents("price") & "')"

numinserted = 0
conn.Execute sql, numinserted

numinserted will contain the number of inserted records (normally 1) so you can check if the insert was executed correctly like


conn.Execute sql, numinserted

if numinserted <> 1 then
response.write("Databaseproblem")
else
rest of your code
end if

carol
10-12-2003, 02:15 PM
okay tryed all that

but am back to the same error i originally had

Microsoft JET Database Engine (0x80004005)
Operation must use an updateable query.


conn.Execute sql, numinserted

maybe access is corrupt and needs reseting up

thats of your help is great appreciated



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum