473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Application uses a variable of the wrong type...

Hi

I have a ASP and SQL Server website which uses a couple of Stored
Procedures during the Shopping Cart process. 1 inserts the Customer
information into a table and the next inserts the Payment information
into a table.

I don't have access to the code now, but have found that many of our
customers, especially those who use I.E 6 are having problems with a

" -2146824867 Application uses a value of the wrong type for the
current operation"

error message which occurs when the Stored Procedure is executed.

I have looked through the Google archive but can't find anything
specific about this message. Could anyone tell me if there is a known
issue with IE6 and Datatypes with Stored Procedures, and if so how to
resolve it? I will post the code later today if anyone thinks it will
help.

Regards

Richard
Jul 19 '05 #1
4 12512
Richard Davies wrote:
Hi

I have a ASP and SQL Server website which uses a couple of Stored
Procedures during the Shopping Cart process. 1 inserts the Customer
information into a table and the next inserts the Payment information
into a table.

I don't have access to the code now, but have found that many of our
customers, especially those who use I.E 6 are having problems with a

" -2146824867 Application uses a value of the wrong type for the
current operation"

error message which occurs when the Stored Procedure is executed.

I have looked through the Google archive but can't find anything
specific about this message. Could anyone tell me if there is a known
issue with IE6 and Datatypes with Stored Procedures,
None that I've seen
and if so how to
resolve it? I will post the code later today if anyone thinks it will
help.

<chuckle> post the code.
Jul 19 '05 #2
:-)
PS. Please post only the relevant portion of the code. We don't need to see
the entire page, html and all. Just the snippet where you set the parameter
values and execute the stored procedure.
Jul 19 '05 #3
PS. Please post only the relevant portion of the code. We don't need to see the entire page, html and all. Just the snippet where you set the parameter values and execute the stored procedure.


Hi

Here is the relevant code from the page:

<%
set rsCountry = Server.CreateObject("ADODB.Recordset")
rsCountry.ActiveConnection = MM_connrails_STRING
rsCountry.Source = "SELECT CountryName FROM dbo.tblcountry ORDER BY
CountryName ASC"
rsCountry.CursorType = 0
rsCountry.CursorLocation = 2
rsCountry.LockType = 3
rsCountry.Open()
rsCountry_numRows = 0
%>
<%

Dim Command1__title
Command1__title = ""
if(Request("title") <> "") then Command1__title = Request("title")

Dim Command1__fname
Command1__fname = ""
if(Request.Form("FirstName") <> "") then Command1__fname =
Request.Form("FirstName")

Dim Command1__lname
Command1__lname = ""
if(Request.Form("LastName") <> "") then Command1__lname =
Request.Form("LastName")

Dim Command1__cemail
Command1__cemail = ""
if(Request.Form("CustomerEmail") <> "") then Command1__cemail =
Request.Form("CustomerEmail")

Dim Command1__billadd1
Command1__billadd1 = ""
if(Request.Form("BillingAddress1") <> "") then Command1__billadd1 =
Request.Form("BillingAddress1")

Dim Command1__billadd2
Command1__billadd2 = ""
if(Request.Form("BillingAddress2") <> "") then Command1__billadd2 =
Request.Form("BillingAddress2")

Dim Command1__billcity
Command1__billcity = ""
if(Request.Form("BillingCity") <> "") then Command1__billcity =
Request.Form("BillingCity")

Dim Command1__billregion
Command1__billregion = ""
if(Request.Form("BillingState") <> "") then Command1__billregion =
Request.Form("BillingState")

Dim Command1__billpostcode
Command1__billpostcode = ""
if(Request.Form("BillingPostalcode") <> "") then Command1__billpostcode =
Request.Form("BillingPostalcode")

Dim Command1__billcountry
Command1__billcountry = ""
if(Request.Form("BillingCountryID") <> "") then Command1__billcountry =
Request.Form("BillingCountryID")

Dim Command1__phone
Command1__phone = ""
if(Request.Form("Phone") <> "") then Command1__phone = Request.Form("Phone")

Dim Command1__deladd1
Command1__deladd1 = ""
if(Request.Form("DeliveryAddress1") <> "") then Command1__deladd1 =
Request.Form("DeliveryAddress1")

Dim Command1__deladd2
Command1__deladd2 = ""
if(Request.Form("DeliveryAddress2") <> "") then Command1__deladd2 =
Request.Form("DeliveryAddress2")

Dim Command1__scity
Command1__scity = ""
if(Request.Form("DeliveryCity") <> "") then Command1__scity =
Request.Form("DeliveryCity")

Dim Command1__sregion
Command1__sregion = ""
if(Request.Form("deliverystate") <> "") then Command1__sregion =
Request.Form("deliverystate")

Dim Command1__spostcode
Command1__spostcode = ""
if(Request.Form("DeliveryPostalcode") <> "") then Command1__spostcode =
Request.Form("DeliveryPostalcode")

Dim Command1__shipcountry
Command1__shipcountry = ""
if(Request.Form("DeliveryCountryID") <> "") then Command1__shipcountry =
Request.Form("DeliveryCountryID")

Dim Command1__special
Command1__special = ""
if(Request.Form("SpecialInstructions") <> "") then Command1__special =
Request.Form("SpecialInstructions")

%>
<%
' *** Edit Operations: declare variables

MM_editAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
If (Request.Form("flag") = "add")Then
set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_connrails_STRING
Command1.CommandText = "dbo.spcheckout1"
Command1.Parameters.Append Command1.CreateParameter("@title", 200,
1,50,Command1__title)
Command1.Parameters.Append Command1.CreateParameter("@fname", 200,
1,50,Command1__fname)
Command1.Parameters.Append Command1.CreateParameter("@lname", 200,
1,50,Command1__lname)
Command1.Parameters.Append Command1.CreateParameter("@cemail", 200,
1,50,Command1__cemail)
Command1.Parameters.Append Command1.CreateParameter("@billadd1", 200,
1,50,Command1__billadd1)
Command1.Parameters.Append Command1.CreateParameter("@billadd2", 200,
1,50,Command1__billadd2)
Command1.Parameters.Append Command1.CreateParameter("@billcity", 200,
1,50,Command1__billcity)
Command1.Parameters.Append Command1.CreateParameter("@billregion", 200,
1,50,Command1__billregion)
Command1.Parameters.Append Command1.CreateParameter("@billpostcode", 200,
1,50,Command1__billpostcode)
Command1.Parameters.Append Command1.CreateParameter("@billcountry", 200,
1,50,Command1__billcountry)
Command1.Parameters.Append Command1.CreateParameter("@phone", 200,
1,50,Command1__phone)
Command1.Parameters.Append Command1.CreateParameter("@deladd1", 200,
1,50,Command1__deladd1)
Command1.Parameters.Append Command1.CreateParameter("@deladd2", 200,
1,50,Command1__deladd2)
Command1.Parameters.Append Command1.CreateParameter("@scity", 200,
1,50,Command1__scity)
Command1.Parameters.Append Command1.CreateParameter("@sregion", 200,
1,50,Command1__sregion)
Command1.Parameters.Append Command1.CreateParameter("@spostcode", 200,
1,50,Command1__spostcode)
Command1.Parameters.Append Command1.CreateParameter("@shipcountry", 200,
1,50,Command1__shipcountry)
Command1.Parameters.Append Command1.CreateParameter("@special", 200,
1,200,Command1__special)
Command1.Parameters.Append Command1.CreateParameter("@Ident", 3, 4)
Command1.CommandType = 4
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()
LastIdent = Command1.Parameters("@Ident")
Session("customerid")=LastIdent
Response.Redirect "/shop/checkout2.asp"
End if
%>
<html>

Here is the Stored Procedure:

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[spcheckout1]') and OBJECTPROPERTY(id, N'IsProcedure') =
1)
drop procedure [dbo].[spcheckout1]
GO

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE [dbo].[spcheckout1]
@title nvarchar(50),
@fname nvarchar(50),
@lname nvarchar(50),
@cemail nvarchar(50),
@billadd1 nvarchar(50),
@billadd2 nvarchar(50),
@billcity nvarchar(50),
@billregion nvarchar(50),
@billpostcode nvarchar(50),
@billcountry nvarchar(50),
@phone nvarchar(50),
@deladd1 nvarchar(50),
@deladd2 nvarchar(50),
@scity nvarchar(50),
@sregion nvarchar(50),
@spostcode nvarchar(50),
@shipcountry nvarchar(50),
@special nvarchar(200),
@Ident int OUTPUT
AS
SET NOCOUNT ON
insert into dbo.tblCustomer
(Title,FirstName,LastName,CustomerEmail,BillingAdd ress1,BillingAddress2,
BillingCity,BillingRegion,BillingPostalCode,Billin gCountry,Phone,DeliveryAdd
ress1,DeliveryAddress2,
DeliveryCity,DeliveryRegion,DeliveryPostalCode,Del iveryCountry,SpecialInstru
ctions) values
(@title,@fname,@lname,@cemail,@billadd1,@billadd2, @billcity,@billregion,@bil
lpostcode,
@billcountry,@phone,@deladd1,@deladd2,@scity,@sreg ion,@spostcode,@shipcountr
y,@special)
SET NOCOUNT OFF
SELECT @Ident = @@IDENTITY
RETURN @Ident
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

Cheers

Richard
Jul 19 '05 #4
OK, my initial thought regarding your sproc: why use nvarchar? Do you need
to support international (unicode) characters? If not, you don't need to be
using "n" datatypes.

The Parameters collection of the Command object looks to be well-formed ...
I suggest you use the ADO constants (adCmdStoredProc instead of 4 when
setting the CommandType, etc.) rather than the numeric values for the
arguments: it will make your code more self-documenting. Of course, that
will mean that you will have to include the declarations for the constants:
you can do that by #including the adovbs.inc file which can be found in your
Program Files\Common Files\System\ADO folder. Or, better yet, by using the
technique described here:
http://www.aspfaq.com/show.asp?id=2112

I have a stored procedure code generator that eases the process of creating
these CreateParameter statements. It's available here:
http://www.thrasherwebdesign.com/ind...asp&c=&a=clear.
An example of the ADO code generated for your procedure appears below.

I suggest that you explicitly force all your variables to the proper data
subtypes (string) using CStr. And instead of "if Request("title") <> ""
then", use "if len(Request("title")) > 0 then".

Dim cmd, param

Set cmd=server.CreateObject("ADODB.Command")
With cmd
.CommandType=adcmdstoredproc
.CommandText = "spcheckout1"
set .ActiveConnection=cnSQL
set param = .createparameter("RETURN_VALUE", adInteger,
adParamReturnValue, 0)
.parameters.append param
set param = .createparameter("@title", adVarWChar, adParamInput, 50, [put
value here])
.parameters.append param
set param = .createparameter("@fname", adVarWChar, adParamInput, 50, [put
value here])
.parameters.append param
set param = .createparameter("@lname", adVarWChar, adParamInput, 50, [put
value here])
.parameters.append param
set param = .createparameter("@cemail", adVarWChar, adParamInput, 50, [put
value here])
.parameters.append param
set param = .createparameter("@billadd1", adVarWChar, adParamInput, 50,
[put value here])
.parameters.append param
set param = .createparameter("@billadd2", adVarWChar, adParamInput, 50,
[put value here])
.parameters.append param
set param = .createparameter("@billcity", adVarWChar, adParamInput, 50,
[put value here])
.parameters.append param
set param = .createparameter("@billregion", adVarWChar, adParamInput, 50,
[put value here])
.parameters.append param
set param = .createparameter("@billpostcode", adVarWChar, adParamInput,
50, [put value here])
.parameters.append param
set param = .createparameter("@billcountry", adVarWChar, adParamInput, 50,
[put value here])
.parameters.append param
set param = .createparameter("@phone", adVarWChar, adParamInput, 50, [put
value here])
.parameters.append param
set param = .createparameter("@deladd1", adVarWChar, adParamInput, 50,
[put value here])
.parameters.append param
set param = .createparameter("@deladd2", adVarWChar, adParamInput, 50,
[put value here])
.parameters.append param
set param = .createparameter("@scity", adVarWChar, adParamInput, 50, [put
value here])
.parameters.append param
set param = .createparameter("@sregion", adVarWChar, adParamInput, 50,
[put value here])
.parameters.append param
set param = .createparameter("@spostcode", adVarWChar, adParamInput, 50,
[put value here])
.parameters.append param
set param = .createparameter("@shipcountry", adVarWChar, adParamInput, 50,
[put value here])
.parameters.append param
set param = .createparameter("@special", adVarWChar, adParamInput, 200,
[put value here])
.parameters.append param
set param = .createparameter("@Ident", adInteger, adParamInputOutput, 0,
[put value here])
.parameters.append param
.execute ,,adexecutenorecords
end with

If you do not wish to supply values for your output parameters, replace
adParamInputOutput with adParamOutput
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
7
by: Saso Zagoranski | last post by:
Hi! I mentioned this in my other post today but at that time I though I had it all figured out. When I got a reply regarding my other questing I saw that I don't :) Here's my problem: I...
7
by: Greg Collins [MVP] | last post by:
Hi, I couldn't find what I was looking for by searching the newsgroup, but perhaps these have already been discussed somewhere. This is a bit long with a lot of interrelated questions. What I've...
4
by: Andrew Fisher | last post by:
Hi there. I am finally moving over to ASP.NET as the company I work for is updating certain systems, ,so forgive me if this quesiton has been answered before . I am using C# for this. As a...
2
by: Oberon | last post by:
Why does this not work as it should? I expect index.aspx to show:. Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\ChatSimple\db\chatusers.mdb Instead, I get: ...
9
by: jeff | last post by:
Hi All. I realize that when my Deployed winforms application starts, Windows needs to load the .net 2 framework before control is given to my application.... Is there anyway to either ... -...
9
by: Doug Glancy | last post by:
I got the following code from Francesco Balena's site, for disposing of Com objects: Sub SetNothing(Of T)(ByRef obj As T) ' Dispose of the object if possible If obj IsNot Nothing AndAlso...
0
by: =?Utf-8?B?UG9sbHkgQW5uYQ==?= | last post by:
Hi, I have previously used EL v 3.1 Exception Handling application block successfully. I thought I would now try to do the same with EL v 4.0. My first experiment was to replace an exception....
4
by: jdom | last post by:
i have been struggling with this error for a while , i changed to many times to make sure no error but no luck Error on line 29 strsql.Parameters("@columna") = strmake <%
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.