Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a new record to the database

Status
Not open for further replies.

cheekynorton

Technical User
Jan 21, 2002
12
0
0
GB
Hi, Im new to asp and need some help badly.
Below is the code used for an asp page used to add a new record to the database

<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include virtual=&quot;/adovbs.inc&quot;-->
<%
Dim objConn
Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
objConn.ConnectionString=&quot;DRIVER={Microsoft Access Driver (*.mdb)};&quot; & _ &quot;DBQ=C:\inetpub\objConn.Open
Dim objRS
Set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
objRS.Open &quot;details&quot;, objConn, , adLockOptimistic
objRS.AddNew
objRS(&quot;Name&quot;) = Request.Form(&quot;Name&quot;)
objRS.Update
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>
<HTML>
<BODY>
Thankyou for choosing to stay with us.
</BODY>
</HTML>

When entering a value on the form (ive not included the html for the form page) and clicking the submit button the following error appears :-

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
/Database/registeruser.asp, line 16

the error keeps referring to the objRS.Update line.
Can anyone guide me? Is the code wrong? Can anyone recommend any useful websites?
Many thanks for your help!

Adrian
 
I would recommend adding the cursor type to your open statement, I do not know if not including it uses some default value.

objRS.Open &quot;details&quot;, objConn, adOpenDynamic, adLockOptimistic

 
thanks for the reply
i added as you recommend but the same error still appears :(
 
OOOOOOOOO idea #2
objRS.Open &quot;Select Name from details&quot;, objConn, adOpenDynamic, adLockOptimistic

I believe originally you have selected the whole table multiple rows if they exist and then are trying to update a field and the Access manager is saying which row do you what to update.
Sorry for the first blunder
 
Thanks for your help.
Just fixed the problem.
The problem was that im working on Win2000 and the security hadnt been set to write for 'everyone' in the file's properites.
Many thanks for your time and help hdougl1.
Stupid really!! I shouldve checked it!! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top