|
 |
asp_database_setup thread: ASP error - Arguments of the wrong type......
Message #1 by "Adam" <adam@k...> on Tue, 22 Oct 2002 14:46:58
|
|
Hi there,
Hoping someone might be able to help me on this: I'm getting the error
below having copied it out of the book and applying it to one of my
databases. Do you know what might be wrong?
Error Type:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.
This is the relevant code:
Dim objRS
Set objRS = Server.createobject("ADODB.Recordset")
objrs.Open "tblBuyer", objCon, , adLockOptimistic, adCmdTable
objRS.AddNew
objRS("CustomerTitle") = Request.Form("CustomerTitle")
objRS("CustomerFirstName") = Request.Form("CustomerFirstName")
objRS("CustomerSurname") = Request.Form("CustomerSurname")
objRS("CustomerTel") = Request.Form("CustomerTel")
objRS("CustomerEmail") = Request.Form("CustomerEmail")
objRS("CustomerCountry") = Request.Form("CustomerCountry")
objRS("CustomerTown") = Request.Form("CustomerTown")
objRS("Delivery1") = Request.Form("Delivery1")
objRS("Delivery2") = Request.Form("Delivery2")
objRS("Delivery3") = Request.Form("Delivery3")
objRS("Delivery4") = Request.Form("Delivery4")
objRS("DeliveryCode") = Request.Form("DeliveryCode")
objRS.Update
objRS.Close
Set objRS = Nothing
objConClose
Set objCon = Nothing
%>
Please help! thanks
Message #2 by "Mike" <mg188@c...> on Tue, 22 Oct 2002 11:48:07 -0700
|
|
Three things don't look right:
1) objrs.Open "tblBuyer", objCon, , adLockOptimistic, adCmdTable (why the
2 commas after obCon?).
2) Your dim statement doesn't include the ObjCon variable. Maybe it's
global though (declared somewhere else).
3) objConClose (there should be a period between "objCon" and "Close").
These probably aren't the source of the error shown, but you should look at
(1) and (2), and definitely fix (3).
As for the error, try viewing the data received from the forms. You can do
this by putting temporary lines like this in this page:
RESPONSE.WRITE "<P>CustomerTitle= "&Request.Form("CustomerTitle")&"<P>"
(hint: I usually capitalize these temp lines so I can easily spot them
later when I'm ready to remove them. The <P> tags just help to read the
output)
Do this for all the suspect items you're pulling from the form. To make
sure the results appear before the error interrupts your code, I'd put these
BEFORE the line:
Set objRS = Server.createobject("ADODB.Recordset")
Then I'd take a look at the output ("CustomerTitle=... , etc) and look for
clues why this might cause a hiccup.
If this doesn't help, I'd try to isolate the error as follows:
Starting at the bottom of the suspect code, I'd comment out (by putting a '
at the start of the line) one line or group of code at a time and test.
When "commented out" a line, a line is bypassed in the code execution. When
you test and the error appears, you know it's in the line or group that you
just commented out. As you're commenting out, make sure not to introduce
new errors by breaking up loops or "if/end if" groups. For example, don't
comment out an "end if" line, but leave it's corresponding "if" line
intact - in fact, you should usually comment out all the code in between the
two. Sometimes I'll temporarily comment out lines that change the database
(update, delete, insert) while I'm running these tests. That way, I don't
have to clean up the db later. I expect others have more sophisticated ways
to track errors, but this usually works for me. It's a little tedious, but
goes pretty quick once you get used to it.
hth
ps: did you put a <% somewhere before the dim statement?
----- Original Message -----
From: "Adam" <adam@k...>
To: "ASP Database Setup" <asp_database_setup@p...>
Sent: Tuesday, October 22, 2002 2:46 PM
Subject: [asp_database_setup] ASP error - Arguments of the wrong type......
> Hi there,
>
> Hoping someone might be able to help me on this: I'm getting the error
> below having copied it out of the book and applying it to one of my
> databases. Do you know what might be wrong?
>
> Error Type:
> ADODB.Recordset (0x800A0BB9)
> Arguments are of the wrong type, are out of acceptable range, or are in
> conflict with one another.
>
> This is the relevant code:
>
> Dim objRS
> Set objRS = Server.createobject("ADODB.Recordset")
> objrs.Open "tblBuyer", objCon, , adLockOptimistic, adCmdTable
> objRS.AddNew
> objRS("CustomerTitle") = Request.Form("CustomerTitle")
> objRS("CustomerFirstName") = Request.Form("CustomerFirstName")
> objRS("CustomerSurname") = Request.Form("CustomerSurname")
> objRS("CustomerTel") = Request.Form("CustomerTel")
> objRS("CustomerEmail") = Request.Form("CustomerEmail")
> objRS("CustomerCountry") = Request.Form("CustomerCountry")
> objRS("CustomerTown") = Request.Form("CustomerTown")
> objRS("Delivery1") = Request.Form("Delivery1")
> objRS("Delivery2") = Request.Form("Delivery2")
> objRS("Delivery3") = Request.Form("Delivery3")
> objRS("Delivery4") = Request.Form("Delivery4")
> objRS("DeliveryCode") = Request.Form("DeliveryCode")
> objRS.Update
> objRS.Close
> Set objRS = Nothing
> objConClose
> Set objCon = Nothing
> %>
>
> Please help! thanks
%%email.unsub%%
>
>
Message #3 by "Drew, Ron" <RDrew@B...> on Tue, 22 Oct 2002 15:39:18 -0400
|
|
Could be you just need the adovbs.inc
<%
Dim DB_CONNECTIONSTRING
DB_CONNECTIONSTRING =3D "Provider=3DMicrosoft.Jet.OLEDB.4.0;" _
& "Data Source=3D" & Server.Mappath("db_dsn.mdb") & ";"
DB_CONNECTIONSTRING =3D Application("SQLConnString")
%>
<!-- #INCLUDE FILE=3D"adovbs.inc" -->
<%
Dim I ' Standard looping var
Dim strSQL ' String variable for building our query
Dim iRecordAdded ' Id of added record
Dim objRecordset
Set objRecordset =3D Server.CreateObject("ADODB.Recordset")
' The syntax for the open command is
' recordset.Open Source, ActiveConnection, CursorType, LockType,
Options
'
' Source
' In this case it's our SQL statement. It could also be a
' Table Name, a command object, or a stored procedure.
' ActiveConnection
' We use a string which contains connection information. It
could also
' be a connection object which is faster if you need to open
multiple
' recordsets.
' CursorType
' Doesn't matter too much in this case since I'm not going to
be doing
' much with the records. I'm opening it as a static so I can
get a
' recordcount.
' LockType
' Specifies how the provider should lock the data. We'll use
pessimistic
' so that it'll lock as soon as we start editing and basically
ensure a
' successful update.
' Options
' Tells what type of source we're using if it's not a command
object
strSQL =3D "SELECT * FROM scratch WHERE 0=3D1;"
objRecordset.Open strSQL, DB_CONNECTIONSTRING, adOpenKeyset,
adLockPessimistic, adCmdText
objRecordset.AddNew
objRecordset.Fields("text_field") =3D
CStr(WeekdayName(WeekDay(Date())))
' Integer Data Type
objRecordset.Fields("integer_field") =3D CInt(Day(Now()))
' Date / Time Data Type
objRecordset.Fields("date_time_field") =3D Now()
objRecordset.Update
' Get the DB assigned ID of the record we just added.
iRecordAdded =3D objRecordset.Fields("id").Value
Response.Write "Record id " & iRecordAdded & " added!"
objRecordset.Close
Set objRecordset =3D Nothing
-----Original Message-----
From: Adam [mailto:adam@k...]
Sent: Tuesday, October 22, 2002 10:47 AM
To: ASP Database Setup
Subject: [asp_database_setup] ASP error - Arguments of the wrong
type......
Hi there,
Hoping someone might be able to help me on this: I'm getting the error
below having copied it out of the book and applying it to one of my
databases. Do you know what might be wrong?
Error Type:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.
This is the relevant code:
Dim objRS
Set objRS =3D Server.createobject("ADODB.Recordset")
objrs.Open "tblBuyer", objCon, , adLockOptimistic, adCmdTable
objRS.AddNew
objRS("CustomerTitle") =3D Request.Form("CustomerTitle")
objRS("CustomerFirstName") =3D Request.Form("CustomerFirstName")
objRS("CustomerSurname") =3D Request.Form("CustomerSurname")
objRS("CustomerTel") =3D Request.Form("CustomerTel")
objRS("CustomerEmail") =3D Request.Form("CustomerEmail")
objRS("CustomerCountry") =3D Request.Form("CustomerCountry")
objRS("CustomerTown") =3D Request.Form("CustomerTown")
objRS("Delivery1") =3D Request.Form("Delivery1")
objRS("Delivery2") =3D Request.Form("Delivery2")
objRS("Delivery3") =3D Request.Form("Delivery3")
objRS("Delivery4") =3D Request.Form("Delivery4")
objRS("DeliveryCode") =3D Request.Form("DeliveryCode")
objRS.Update
objRS.Close
Set objRS =3D Nothing
objConClose
Set objCon =3D Nothing
%>
Please help! thanks
%%email.unsub%%
Message #4 by "Ken Schaefer" <ken@a...> on Wed, 23 Oct 2002 10:47:57 +1000
|
|
www.adopenstatic.com/faq/800a0bb9step2.asp probably has the solution to your
problem
You really should have <%Option Explicit%> at the top of your code!
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Adam" <adam@k...>
Subject: [asp_database_setup] ASP error - Arguments of the wrong type......
: Hi there,
:
: Hoping someone might be able to help me on this: I'm getting the error
: below having copied it out of the book and applying it to one of my
: databases. Do you know what might be wrong?
:
: Error Type:
: ADODB.Recordset (0x800A0BB9)
: Arguments are of the wrong type, are out of acceptable range, or are in
: conflict with one another.
:
: This is the relevant code:
:
: Dim objRS
: Set objRS = Server.createobject("ADODB.Recordset")
: objrs.Open "tblBuyer", objCon, , adLockOptimistic, adCmdTable
: objRS.AddNew
: objRS("CustomerTitle") = Request.Form("CustomerTitle")
: objRS("CustomerFirstName") = Request.Form("CustomerFirstName")
: objRS("CustomerSurname") = Request.Form("CustomerSurname")
: objRS("CustomerTel") = Request.Form("CustomerTel")
: objRS("CustomerEmail") = Request.Form("CustomerEmail")
: objRS("CustomerCountry") = Request.Form("CustomerCountry")
: objRS("CustomerTown") = Request.Form("CustomerTown")
: objRS("Delivery1") = Request.Form("Delivery1")
: objRS("Delivery2") = Request.Form("Delivery2")
: objRS("Delivery3") = Request.Form("Delivery3")
: objRS("Delivery4") = Request.Form("Delivery4")
: objRS("DeliveryCode") = Request.Form("DeliveryCode")
: objRS.Update
: objRS.Close
: Set objRS = Nothing
: objConClose
: Set objCon = Nothing
: %>
:
Message #5 by "Ken Schaefer" <ken@a...> on Wed, 23 Oct 2002 10:48:31 +1000
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Mike" <mg188@c...>
Subject: [asp_database_setup] Re: ASP error - Arguments of the wrong
type......
: Three things don't look right:
:
: 1) objrs.Open "tblBuyer", objCon, , adLockOptimistic, adCmdTable (why
the
: 2 commas after obCon?).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Because he's choosing not to supply a cursor type, and relying on the
default instead.
Cheers
Ken
Message #6 by "Mike" <mg188@c...> on Wed, 23 Oct 2002 10:10:31 -0700
|
|
thanks Ken.
I saw in your other post that he should use <%Option Explicit%>. What would
that have shown besides the lack of declaring objCon? Or is that what you
were getting at?
Adam's original code:
Dim objRS
: Set objRS = Server.createobject("ADODB.Recordset")
: objrs.Open "tblBuyer", objCon, , adLockOptimistic, adCmdTable
: objRS.AddNew
: objRS("CustomerTitle") = Request.Form("CustomerTitle")
: objRS("CustomerFirstName") = Request.Form("CustomerFirstName")
: objRS("CustomerSurname") = Request.Form("CustomerSurname")
: objRS("CustomerTel") = Request.Form("CustomerTel")
: objRS("CustomerEmail") = Request.Form("CustomerEmail")
: objRS("CustomerCountry") = Request.Form("CustomerCountry")
: objRS("CustomerTown") = Request.Form("CustomerTown")
: objRS("Delivery1") = Request.Form("Delivery1")
: objRS("Delivery2") = Request.Form("Delivery2")
: objRS("Delivery3") = Request.Form("Delivery3")
: objRS("Delivery4") = Request.Form("Delivery4")
: objRS("DeliveryCode") = Request.Form("DeliveryCode")
: objRS.Update
: objRS.Close
: Set objRS = Nothing
: objConClose
: Set objCon = Nothing
: %>
Regards,
Mike
ps - I finally worked out that referential integrity problem from a week or
2 back - db in 3rd normal form now.
----- Original Message -----
From: "Ken Schaefer" <ken@a...>
To: "ASP Database Setup" <asp_database_setup@p...>
Sent: Tuesday, October 22, 2002 5:48 PM
Subject: [asp_database_setup] Re: ASP error - Arguments of the wrong
type......
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> From: "Mike" <mg188@c...>
> Subject: [asp_database_setup] Re: ASP error - Arguments of the wrong
> type......
>
>
> : Three things don't look right:
> :
> : 1) objrs.Open "tblBuyer", objCon, , adLockOptimistic, adCmdTable (why
> the
> : 2 commas after obCon?).
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Because he's choosing not to supply a cursor type, and relying on the
> default instead.
>
> Cheers
> Ken
Message #7 by "Ken Schaefer" <ken@a...> on Thu, 24 Oct 2002 13:11:37 +1000
|
|
It may have shown that adLockOptimistic is undefined, or adCmdTable, or
objCon etc (for example he may have opened a connection and assigned it to
objConn not objCon)
<%Option Explicit%> is simply good progamming practice, unless you are an
infallible programmer that never makes mistakes (and all the programmers
after you who will be maintaining your code are also infallible).
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Mike" <mg188@c...>
Subject: [asp_database_setup] Re: ASP error - Arguments of the wrong
type......
: thanks Ken.
:
: I saw in your other post that he should use <%Option Explicit%>. What
would
: that have shown besides the lack of declaring objCon? Or is that what you
: were getting at?
:
: Adam's original code:
:
: Dim objRS
: : Set objRS = Server.createobject("ADODB.Recordset")
: : objrs.Open "tblBuyer", objCon, , adLockOptimistic, adCmdTable
: : objRS.AddNew
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Message #8 by "Adam H-W" <adam_hw@k...> on Thu, 24 Oct 2002 08:38:47 +0100
|
|
Mike
Thanks very much - I'll check out your pointers.
Adam
Tel: 0208 877 0077
Fax:0208 874 7851
adam_hw@k...
----- Original Message -----
From: "Mike" <mg188@c...>
To: "ASP Database Setup" <asp_database_setup@p...>
Sent: Tuesday, October 22, 2002 7:48 PM
Subject: [asp_database_setup] Re: ASP error - Arguments of the wrong
type......
> Three things don't look right:
>
> 1) objrs.Open "tblBuyer", objCon, , adLockOptimistic, adCmdTable (why
the
> 2 commas after obCon?).
> 2) Your dim statement doesn't include the ObjCon variable. Maybe it's
> global though (declared somewhere else).
> 3) objConClose (there should be a period between "objCon" and "Close").
>
> These probably aren't the source of the error shown, but you should look
at
> (1) and (2), and definitely fix (3).
>
> As for the error, try viewing the data received from the forms. You can
do
> this by putting temporary lines like this in this page:
>
> RESPONSE.WRITE "<P>CustomerTitle= "&Request.Form("CustomerTitle")&"<P>"
>
> (hint: I usually capitalize these temp lines so I can easily spot them
> later when I'm ready to remove them. The <P> tags just help to read the
> output)
>
> Do this for all the suspect items you're pulling from the form. To make
> sure the results appear before the error interrupts your code, I'd put
these
> BEFORE the line:
>
> Set objRS = Server.createobject("ADODB.Recordset")
>
> Then I'd take a look at the output ("CustomerTitle=... , etc) and look for
> clues why this might cause a hiccup.
>
> If this doesn't help, I'd try to isolate the error as follows:
> Starting at the bottom of the suspect code, I'd comment out (by putting a
'
> at the start of the line) one line or group of code at a time and test.
> When "commented out" a line, a line is bypassed in the code execution.
When
> you test and the error appears, you know it's in the line or group that
you
> just commented out. As you're commenting out, make sure not to introduce
> new errors by breaking up loops or "if/end if" groups. For example, don't
> comment out an "end if" line, but leave it's corresponding "if" line
> intact - in fact, you should usually comment out all the code in between
the
> two. Sometimes I'll temporarily comment out lines that change the
database
> (update, delete, insert) while I'm running these tests. That way, I don't
> have to clean up the db later. I expect others have more sophisticated
ways
> to track errors, but this usually works for me. It's a little tedious,
but
> goes pretty quick once you get used to it.
>
> hth
>
> ps: did you put a <% somewhere before the dim statement?
>
>
> ----- Original Message -----
> From: "Adam" <adam@k...>
> To: "ASP Database Setup" <asp_database_setup@p...>
> Sent: Tuesday, October 22, 2002 2:46 PM
> Subject: [asp_database_setup] ASP error - Arguments of the wrong
type......
>
>
> > Hi there,
> >
> > Hoping someone might be able to help me on this: I'm getting the error
> > below having copied it out of the book and applying it to one of my
> > databases. Do you know what might be wrong?
> >
> > Error Type:
> > ADODB.Recordset (0x800A0BB9)
> > Arguments are of the wrong type, are out of acceptable range, or are in
> > conflict with one another.
> >
> > This is the relevant code:
> >
> > Dim objRS
> > Set objRS = Server.createobject("ADODB.Recordset")
> > objrs.Open "tblBuyer", objCon, , adLockOptimistic, adCmdTable
> > objRS.AddNew
> > objRS("CustomerTitle") = Request.Form("CustomerTitle")
> > objRS("CustomerFirstName") = Request.Form("CustomerFirstName")
> > objRS("CustomerSurname") = Request.Form("CustomerSurname")
> > objRS("CustomerTel") = Request.Form("CustomerTel")
> > objRS("CustomerEmail") = Request.Form("CustomerEmail")
> > objRS("CustomerCountry") = Request.Form("CustomerCountry")
> > objRS("CustomerTown") = Request.Form("CustomerTown")
> > objRS("Delivery1") = Request.Form("Delivery1")
> > objRS("Delivery2") = Request.Form("Delivery2")
> > objRS("Delivery3") = Request.Form("Delivery3")
> > objRS("Delivery4") = Request.Form("Delivery4")
> > objRS("DeliveryCode") = Request.Form("DeliveryCode")
> > objRS.Update
> > objRS.Close
> > Set objRS = Nothing
> > objConClose
> > Set objCon = Nothing
> > %>
> >
> > Please help! thanks
> %%email.unsub%%
> >
> >
>
>
adam_hw@k...
%%email.unsub%%
>
>
Message #9 by "Adam H-W" <adam@k...> on Thu, 24 Oct 2002 08:41:04 +0100
|
|
Great, thanks Ken
Tel: 0208 877 0077
Fax:0208 874 7851
adam_hw@k...
----- Original Message -----
From: "Ken Schaefer" <ken@a...>
To: "ASP Database Setup" <asp_database_setup@p...>
Sent: Wednesday, October 23, 2002 1:47 AM
Subject: [asp_database_setup] Re: ASP error - Arguments of the wrong
type......
> www.adopenstatic.com/faq/800a0bb9step2.asp probably has the solution to
your
> problem
>
> You really should have <%Option Explicit%> at the top of your code!
>
> Cheers
> Ken
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> From: "Adam" <adam@k...>
> Subject: [asp_database_setup] ASP error - Arguments of the wrong
type......
>
>
> : Hi there,
> :
> : Hoping someone might be able to help me on this: I'm getting the error
> : below having copied it out of the book and applying it to one of my
> : databases. Do you know what might be wrong?
> :
> : Error Type:
> : ADODB.Recordset (0x800A0BB9)
> : Arguments are of the wrong type, are out of acceptable range, or are in
> : conflict with one another.
> :
> : This is the relevant code:
> :
> : Dim objRS
> : Set objRS = Server.createobject("ADODB.Recordset")
> : objrs.Open "tblBuyer", objCon, , adLockOptimistic, adCmdTable
> : objRS.AddNew
> : objRS("CustomerTitle") = Request.Form("CustomerTitle")
> : objRS("CustomerFirstName") = Request.Form("CustomerFirstName")
> : objRS("CustomerSurname") = Request.Form("CustomerSurname")
> : objRS("CustomerTel") = Request.Form("CustomerTel")
> : objRS("CustomerEmail") = Request.Form("CustomerEmail")
> : objRS("CustomerCountry") = Request.Form("CustomerCountry")
> : objRS("CustomerTown") = Request.Form("CustomerTown")
> : objRS("Delivery1") = Request.Form("Delivery1")
> : objRS("Delivery2") = Request.Form("Delivery2")
> : objRS("Delivery3") = Request.Form("Delivery3")
> : objRS("Delivery4") = Request.Form("Delivery4")
> : objRS("DeliveryCode") = Request.Form("DeliveryCode")
> : objRS.Update
> : objRS.Close
> : Set objRS = Nothing
> : objConClose
> : Set objCon = Nothing
> : %>
> :
>
>
%%email.unsub%%
>
>
|
|
 |