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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Records to Access Database

Status
Not open for further replies.

jtgurkin

Technical User
Sep 16, 2002
47
US
I have the following ASP code in my Add Data page. (This is me getting my feet wet with Access & ASP.) I can access the data and view it fine, but when I execute this page, I get the error that follows the code.

--------------------Code--------------------------------

<html>

<head>
<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft FrontPage 5.0&quot;>
<meta name=&quot;ProgId&quot; content=&quot;FrontPage.Editor.Document&quot;>
<title>Untitled Document</title>
</head>

<body>

<%
Dim DBtest
Set DBtest = Server.CreateObject(&quot;ADODB.Connection&quot;)
DBtest.Mode = adModeReadWrite
DBtest.Open (&quot;Provider=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=&quot; + Server.MapPath(&quot;addresses.mdb&quot;))

Dim RStest
Set RStest = Server.CreateObject(&quot;ADODB.Recordset&quot;)
RStest.CursorType = adUseClient
RStest.Open &quot;Addresses&quot;, DBtest, adOpenStatic, adLockOptimistic

RStest.AddNew
RStest (&quot;FirstName&quot;) = &quot;TestFirstName&quot;
RStest (&quot;LastName&quot;) = &quot;TestLastName&quot;
RStest.Update

%>
<p>Success!! </p>

</body>

</html>

-------------------ERROR-------------------------------

ADODB.Recordset error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/chemteach/dbtest/add2.asp, line 20
 
This line:
Code:
RStest.Open &quot;Addresses&quot;, DBtest, adOpenStatic, adLockOptimistic
Needs to have a valid SQL query instead of
Code:
&quot;Addresses&quot;
. For example, in order to select everything in the table you'd change it to:
Code:
RStest.Open &quot;SELECT * FROM Addresses&quot;, DBtest, adOpenStatic, adLockOptimistic
 
Oops, I see that you're trying to update rather than select, sorry.
 
Here's a suggestion that actually has to do with updating. :)

Add
Code:
, adCmdTable
at the end of your open string.
 
Upon searching around, I found that my adLockOptimistic and other ad... methods needed to be replaced with numbers i.e. RStest.Open &quot;Addresses&quot;, DBtest, 3, 2
as found in faq333-618.
 
Ah, I'd assumed you'd put an include for adovbs.inc at the top of your code. If you do so then you can use the words, otherwise you need to use the numbers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top