Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 ADO Error with command object
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

q2w
Starting Member

16 Posts

Posted - 30 July 2003 :  11:23:44  Show Profile
This may sound like a Dreamweaver specific question, but I am beginning to think it is not because I cannot get an answer to it (that solves the problem) on the Dreamweaver online forums. There are a bunch of high powered programmer types here, so I thought I would ask.

I have added a plain vanilla command object to my ASP page which is supposed to insert data into an MSSQL table using a stored procedure. It should simply take the values from two text fields and one check box and insert those values into the table. However, I keep getting the following error:

ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

It tells me that the error is occuring on this line:

cmd.Parameters.Append cmd.CreateParameter("@DNS", 901, 1,1,cmd__DNS)

(NOTE: IF you see line wrap in this message, it does not wrap on my page)

The checkbox "checked value" = 1. I have tried initializing the value of the variable cmd_DNS to FALSE and that has not worked. I have tried converting the value of cmd_DNS to CBool and CInt type, and that has not solved the problem.

I completely eliminated that parameter as a test to isolate the problem and the command functioned properly, so my problem does lie with the manner in which I (i.e. Dreamweaver) is passing that boolean parameter.

What am I doing wrong with respect to this boolean parameter that I want to pass using the command to the stored procedure?

------------------------------------------------------------------
MY CODE:
------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="dbcnct/cnct.asp" -->
<%

Dim cmd__FN
cmd__FN = ""
if(Request("FN") <> "") then cmd__FN = Request("FN")

Dim cmd__LN
cmd__LN = ""
if(Request("LN") <> "") then cmd__LN = Request("LN")

Dim cmd__DNS
cmd__DNS = ""
if(Request("DNS") <> "") then cmd__DNS = Request("DNS")

%>
<%
If request.form("submit") <> "" then
set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = MM_cnct_STRING
cmd.CommandText = "dbo.sp_AddName"
cmd.Parameters.Append cmd.CreateParameter("@RETURN_VALUE", 3, 4)
cmd.Parameters.Append cmd.CreateParameter("@FN", 200, 1,50,cmd__FN)
cmd.Parameters.Append cmd.CreateParameter("@LN", 200, 1,50,cmd__LN)
cmd.Parameters.Append cmd.CreateParameter("@DNS", 901, 1,1,cmd__DNS)
cmd.CommandType = 4
cmd.CommandTimeout = 0
cmd.Prepared = true
cmd.Execute()
end if
%>
====================================================================
END OF MY CODE
====================================================================

Hamlin
Advanced Member

United Kingdom
2386 Posts

Posted - 30 July 2003 :  11:41:58  Show Profile
If I remember the second from last argument (shown in red) is the size of the argument passed.
cmd.Parameters.Append cmd.CreateParameter("@DNS", 901, 1,1,cmd__DNS)

Try changing that to a larger number.
Go to Top of Page

q2w
Starting Member

16 Posts

Posted - 30 July 2003 :  12:04:06  Show Profile
Thank you Hamlin. It looks like you have solved my problem.

I increased the size to 4 (the same size as an integer in Transact SQL) but that did not solve the problem by itself. However, then I initialized the variable to an integer (0), and combined with your fix, it fixed the problem.

I guess the moral of the story is that in using VBScript to send parameters to SQL Server, you must use data types that native to VBScript, and not those data types expected by SQL Server. I find that odd, but then, who am I to contest the logic of it?

At any rate, thank you.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.58 seconds. Powered By: Snitz Forums 2000 Version 3.4.07