PDA

View Full Version : insert error


webmarkart
03-07-2003, 06:22 AM
I am using a very simple insert code to create a new record in sn Access database:


<%
UserName = Trim(Request("USER_NAME"))
School = Trim(Request("FORUM_SCHOOL"))
Comment = Trim(Request("COMMENT"))
CorNo = Trim(Request("CORNO"))
ForumHeading = Trim(Request("FORUM_HEADING"))

sql = ""
sql = "INSERT INTO SUNY_FORUM "
sql = sql & "(USER_NAME, FORUM_SCHOOL, FORUM_COMMENT, CORRISPONDING_COMMENT_NO, FORUM_HEADING, FORUM_COMMENT_DATE ) "
sql = sql & "VALUES ("
sql = sql & "'" & Replace(UserName, "'", "''") & "', "
sql = sql & "'" & Replace(School, "'", "''") & "', "
sql = sql & "'" & Replace(Comment, "'", "''") & "', "
sql = sql & " " & Replace(CorNo, "'", "''") & ", "
sql = sql & "'" & Replace(ForumHeading, "'", "''") & "', "
sql = sql & " Date() ) "
'Response.Write sql
oConn.Execute sql

rs.Close
Set rs = nothing
%>


I have used the same template to update countless other tables before and I've never gotten this error before:


INSERT INTO SUNY_FORUM (USER_NAME,FORUM_SCHOOL,FORUM_COMMENT,CORRISPONDING_COMMENT_NO,FORUM_HEADING,FORUM_COMMENT_DATE ) VALUES ('ZVXC', 'SDFG', 'SDFGSDFG', 1, 'RE:Testing Forum', Date() )
Microsoft JET Database Engine error '80004005'

Operation must use an updateable query.

/suny/includes/forum_insert_reply.inc, line 19

where line 19 is: "oConn.Execute sql"

I've made sure the database inself and the folder on the server have full read/write permissions... I'm at a loss! Anyone have any ideas?

raf
03-07-2003, 08:49 AM
2 question:
- why close a recordset (you don't need a recordset to insert)
- did you try to leave out the date(both as variabland and as value of coarse)
Im think the problem is with the date. It should be the value instead of Date() )

This can't be right (can it ?)
sql = sql & " Date() ) "

so you'll probably need to have something like

sql = sql & "#adate#)"
sql = replace(sql,adate,Date())

webmarkart
03-07-2003, 04:14 PM
I have tried it without the date and I still get the same error. In fact I have tried it without each variable to try to narrow the problem search. The fustrating thing is that I have used the exact same format before and it has worked without any problems (including the date).

allida77
03-07-2003, 05:09 PM
" Date() ) "


Try removing the "" from the date(). I rarely use access but I know that wouldnt work in other dbs.


sql = sql & Date() & " ) "

webmarkart
03-07-2003, 10:10 PM
Like I've said, I've tried it without the date already. Again, I have used this template before and it works. I'll try it again...

webmarkart
03-07-2003, 10:16 PM
I tried removing the date completely and I still get the same error.
maybe it would help if I posted the url...

http://www.webmarkart.com/suny/default.asp?action=forumdetail&comno=1

it happens when I try to reply to this forum topic...

allida77
03-07-2003, 10:25 PM
Sorry about that. What is your primary key(pk) for the table? You may be trying to update and the pk is not a auto number or not being incremented.

webmarkart
03-07-2003, 10:31 PM
huh, that makes sense. I checked the db and noticed there was no pk icon next to the FORUM_COMMENT_NO field (which there should be). I tried to re-designate it as my pk and it tells me "You already have an index named 'PrimaryKey'" (but I don't). Since there is no real data in this table yet I'm going to delete the table and recreate it. I hope this works... Thanks for the tip!

webmarkart
03-07-2003, 11:15 PM
Damn, I was feeling good about that. I thought that was going to work! Still the same error.

Roy Sinclair
03-07-2003, 11:40 PM
See these MS Knowledge Base (http://search.microsoft.com/Default.asp?&so=RECCNT&boolean=ALL&siteid=us&p=1&nq=NEW&qu=%22Operation+must+use+an+updateable+query%22&IntlSearch=&ig=1&ig=2&ig=3&ig=4&ig=5&ig=6&ig=7&ig=8&ig=9&ig=10&i=00&i=01&i=02&i=03&i=04&i=05&i=06&i=07&i=08&i=09) articles.

whammy
03-08-2003, 03:10 AM
Hmm... you must have fixed the error? I can display your page fine. ;)

webmarkart
03-08-2003, 06:10 AM
It displays, but when I try to insert data into the db I get the error. Just on a whim, I uploaded the entire project to a separate domain account and it worked like a charm! Now I know the problem is with my hosting company. Thanks to everyone that took the time to help out!