I have an ASP page that is being used to instigate a new record in the database, then call back the record ID for that new item. The following is the code of the page:
----------------------------------
<%
Dim strconnect, SQL1, SQL2, Con, PR, rstemp, dirPR, tag
tag = CStr(Now())
response.write tag
strconnect="PR"
SQL1 = "INSERT INTO PReq (identifier, complete) VALUES ('" & tag & "', 'no');"
response.write "<P>" & SQL1
SQL2 = "SELECT PR FROM PReq WHERE PReq.identifier = '" & tag & "';"
response.write "<P>" & SQL2
Set Con = Server.CreateObject("ADODB.Connection")
Con.Open strConnect
Con.Execute(SQL1)
Con.Close
Con.Open strConnect
Set rstemp=Con.Execute(SQL2)
PR = rstemp(0)
dirPR = "PRStartStep1.asp?PR=" & PR
rstemp.Close
Set rstemp = Nothing
Con.Close
Set Con = Nothing
response.write dirPR
%>
--------------------------------------
The following is the result that I get:
--------------------------------------
1/16/2007 2:08:04 PM
INSERT INTO PReq (identifier, complete) VALUES ('1/16/2007 2:08:04 PM', 'no');
SELECT PR FROM PReq WHERE PReq.identifier = '1/16/2007 2:08:04 PM';
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
/pr/PRstart1.asp, line 15
--------------------------------------
Line 15 is Con.Execute(SQL1)
I have compared this error to another ASP page written for a different project, which threw no code and worked. The response.write lines were inserted as I tried to debug the code so that I could see if it was writing the queries as I expected it to. Why is this page not working?
Cheryl dc Kern
----------------------------------
<%
Dim strconnect, SQL1, SQL2, Con, PR, rstemp, dirPR, tag
tag = CStr(Now())
response.write tag
strconnect="PR"
SQL1 = "INSERT INTO PReq (identifier, complete) VALUES ('" & tag & "', 'no');"
response.write "<P>" & SQL1
SQL2 = "SELECT PR FROM PReq WHERE PReq.identifier = '" & tag & "';"
response.write "<P>" & SQL2
Set Con = Server.CreateObject("ADODB.Connection")
Con.Open strConnect
Con.Execute(SQL1)
Con.Close
Con.Open strConnect
Set rstemp=Con.Execute(SQL2)
PR = rstemp(0)
dirPR = "PRStartStep1.asp?PR=" & PR
rstemp.Close
Set rstemp = Nothing
Con.Close
Set Con = Nothing
response.write dirPR
%>
--------------------------------------
The following is the result that I get:
--------------------------------------
1/16/2007 2:08:04 PM
INSERT INTO PReq (identifier, complete) VALUES ('1/16/2007 2:08:04 PM', 'no');
SELECT PR FROM PReq WHERE PReq.identifier = '1/16/2007 2:08:04 PM';
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
/pr/PRstart1.asp, line 15
--------------------------------------
Line 15 is Con.Execute(SQL1)
I have compared this error to another ASP page written for a different project, which threw no code and worked. The response.write lines were inserted as I tried to debug the code so that I could see if it was writing the queries as I expected it to. Why is this page not working?
Cheryl dc Kern