PDA

Click to See Complete Forum and Search --> : Can't make it do the simplest thing!


joey o.
Oct 7th, 2000, 04:55 PM
I found this code in a "ASP FOR DUMMIES" Book. They saw me coming when they made the title. Can anyone help me out here?
I'm trying to use this code to update the database but keep getting this era:
"The application is using arguments that are of the
wrong type, are out of acceptable range, or are in conflict with one another.
filename.asp line 13"

<html>
<head>
<title>
</title>
</Head>
<body>
<%
Dim Connect,rs, Query
Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "NewSite" 'my DSN
set rs = server.CreateObject ("ADODB.Recordset")
Query = "SELECT Tracking.* FROM Tracking;" 'the table name
rs.Open Query,Connect,adOpenStatic,adLockOptimistic
rs.AddNew
'ISSUENUM" is the column name string" is a string
rs("ISSUENUM1") = "string"
rs.Update
%>
</body>
</html>

parksie
Oct 7th, 2000, 04:58 PM
Are your parameters for rs.Open in the right order?

joey o.
Oct 7th, 2000, 05:20 PM
Ya, They look right and I even tried to change the first two and got the same error. The last two are definitly right.

Oct 7th, 2000, 05:36 PM
Remember VBScript has no idea what the values of enums are:

<%

'values used for enums supplied by ADO, found in adovbs.inc

'---- CursorTypeEnum Values ----
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3

'---- LockTypeEnum Values ----
Const adLockReadOnly = 1
Const adLockPessimistic = 2
Const adLockOptimistic = 3
Const adLockBatchOptimistic = 4

Dim rec, con, sql, sConnString


set con = Server.CreateObject ("ADODB.Connection")
con.open "YourDSNGoesHERE"

set rec = Server.CreateObject ("ADODB.Recordset")

'the following query will always return an empty recordset
'but one that allows the addnew method to affect the tracking table
sql = "select tracking.* from tracking where 0=1"

rec.Open sql,con,adOpenKeyset , adLockOptimistic
rec.AddNew
rec("IssueNum") = "Testing!"
rec.Update
rec.Close
set rec = nothing
con.Close
set con = nothing
%>

monte96
Oct 8th, 2000, 12:07 AM
Just add this to your Global.asa document:

<!-- METADATA NAME="Microsoft ActiveX Data Objects 2.5 Library"
TYPE="TypeLib" UUID="{00000205-0000-0010-8000-00AA006D2EA4}" -->


All of the ADO constants will be available throughout your web app.

joey o.
Oct 9th, 2000, 10:33 AM
Thanks Guys,
Your the best!