473,854 Members | 1,835 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 12536
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.CreateOb ject("ADODB.Rec ordset")
rsCountry.Activ eConnection = MM_connrails_ST RING
rsCountry.Sourc e = "SELECT CountryName FROM dbo.tblcountry ORDER BY
CountryName ASC"
rsCountry.Curso rType = 0
rsCountry.Curso rLocation = 2
rsCountry.LockT ype = 3
rsCountry.Open( )
rsCountry_numRo ws = 0
%>
<%

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

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

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

Dim Command1__cemai l
Command1__cemai l = ""
if(Request.Form ("CustomerEmail ") <> "") then Command1__cemai l =
Request.Form("C ustomerEmail")

Dim Command1__billa dd1
Command1__billa dd1 = ""
if(Request.Form ("BillingAddres s1") <> "") then Command1__billa dd1 =
Request.Form("B illingAddress1" )

Dim Command1__billa dd2
Command1__billa dd2 = ""
if(Request.Form ("BillingAddres s2") <> "") then Command1__billa dd2 =
Request.Form("B illingAddress2" )

Dim Command1__billc ity
Command1__billc ity = ""
if(Request.Form ("BillingCit y") <> "") then Command1__billc ity =
Request.Form("B illingCity")

Dim Command1__billr egion
Command1__billr egion = ""
if(Request.Form ("BillingState" ) <> "") then Command1__billr egion =
Request.Form("B illingState")

Dim Command1__billp ostcode
Command1__billp ostcode = ""
if(Request.Form ("BillingPostal code") <> "") then Command1__billp ostcode =
Request.Form("B illingPostalcod e")

Dim Command1__billc ountry
Command1__billc ountry = ""
if(Request.Form ("BillingCountr yID") <> "") then Command1__billc ountry =
Request.Form("B illingCountryID ")

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

Dim Command1__delad d1
Command1__delad d1 = ""
if(Request.Form ("DeliveryAddre ss1") <> "") then Command1__delad d1 =
Request.Form("D eliveryAddress1 ")

Dim Command1__delad d2
Command1__delad d2 = ""
if(Request.Form ("DeliveryAddre ss2") <> "") then Command1__delad d2 =
Request.Form("D eliveryAddress2 ")

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

Dim Command1__sregi on
Command1__sregi on = ""
if(Request.Form ("deliverystate ") <> "") then Command1__sregi on =
Request.Form("d eliverystate")

Dim Command1__spost code
Command1__spost code = ""
if(Request.Form ("DeliveryPosta lcode") <> "") then Command1__spost code =
Request.Form("D eliveryPostalco de")

Dim Command1__shipc ountry
Command1__shipc ountry = ""
if(Request.Form ("DeliveryCount ryID") <> "") then Command1__shipc ountry =
Request.Form("D eliveryCountryI D")

Dim Command1__speci al
Command1__speci al = ""
if(Request.Form ("SpecialInstru ctions") <> "") then Command1__speci al =
Request.Form("S pecialInstructi ons")

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

MM_editAction = CStr(Request("U RL"))
If (Request.QueryS tring <> "") Then
MM_editAction = MM_editAction & "?" & Request.QuerySt ring
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.CreateOb ject("ADODB.Com mand")
Command1.Active Connection = MM_connrails_ST RING
Command1.Comman dText = "dbo.spcheckout 1"
Command1.Parame ters.Append Command1.Create Parameter("@tit le", 200,
1,50,Command1__ title)
Command1.Parame ters.Append Command1.Create Parameter("@fna me", 200,
1,50,Command1__ fname)
Command1.Parame ters.Append Command1.Create Parameter("@lna me", 200,
1,50,Command1__ lname)
Command1.Parame ters.Append Command1.Create Parameter("@cem ail", 200,
1,50,Command1__ cemail)
Command1.Parame ters.Append Command1.Create Parameter("@bil ladd1", 200,
1,50,Command1__ billadd1)
Command1.Parame ters.Append Command1.Create Parameter("@bil ladd2", 200,
1,50,Command1__ billadd2)
Command1.Parame ters.Append Command1.Create Parameter("@bil lcity", 200,
1,50,Command1__ billcity)
Command1.Parame ters.Append Command1.Create Parameter("@bil lregion", 200,
1,50,Command1__ billregion)
Command1.Parame ters.Append Command1.Create Parameter("@bil lpostcode", 200,
1,50,Command1__ billpostcode)
Command1.Parame ters.Append Command1.Create Parameter("@bil lcountry", 200,
1,50,Command1__ billcountry)
Command1.Parame ters.Append Command1.Create Parameter("@pho ne", 200,
1,50,Command1__ phone)
Command1.Parame ters.Append Command1.Create Parameter("@del add1", 200,
1,50,Command1__ deladd1)
Command1.Parame ters.Append Command1.Create Parameter("@del add2", 200,
1,50,Command1__ deladd2)
Command1.Parame ters.Append Command1.Create Parameter("@sci ty", 200,
1,50,Command1__ scity)
Command1.Parame ters.Append Command1.Create Parameter("@sre gion", 200,
1,50,Command1__ sregion)
Command1.Parame ters.Append Command1.Create Parameter("@spo stcode", 200,
1,50,Command1__ spostcode)
Command1.Parame ters.Append Command1.Create Parameter("@shi pcountry", 200,
1,50,Command1__ shipcountry)
Command1.Parame ters.Append Command1.Create Parameter("@spe cial", 200,
1,200,Command1_ _special)
Command1.Parame ters.Append Command1.Create Parameter("@Ide nt", 3, 4)
Command1.Comman dType = 4
Command1.Comman dTimeout = 0
Command1.Prepar ed = true
Command1.Execut e()
LastIdent = Command1.Parame ters("@Ident")
Session("custom erid")=LastIden t
Response.Redire ct "/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_IDENTIFI ER 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,FirstNam e,LastName,Cust omerEmail,Billi ngAddress1,Bill ingAddress2,
BillingCity,Bil lingRegion,Bill ingPostalCode,B illingCountry,P hone,DeliveryAd d
ress1,DeliveryA ddress2,
DeliveryCity,De liveryRegion,De liveryPostalCod e,DeliveryCount ry,SpecialInstr u
ctions) values
(@title,@fname, @lname,@cemail, @billadd1,@bill add2,@billcity, @billregion,@bi l
lpostcode,
@billcountry,@p hone,@deladd1,@ deladd2,@scity, @sregion,@spost code,@shipcount r
y,@special)
SET NOCOUNT OFF
SELECT @Ident = @@IDENTITY
RETURN @Ident
GO
SET QUOTED_IDENTIFI ER 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 (adCmdStoredPro c 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\AD O 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("ti tle")) > 0 then".

Dim cmd, param

Set cmd=server.Crea teObject("ADODB .Command")
With cmd
.CommandType=ad cmdstoredproc
.CommandText = "spcheckout 1"
set .ActiveConnecti on=cnSQL
set param = .createparamete r("RETURN_VALUE ", adInteger,
adParamReturnVa lue, 0)
.parameters.app end param
set param = .createparamete r("@title", adVarWChar, adParamInput, 50, [put
value here])
.parameters.app end param
set param = .createparamete r("@fname", adVarWChar, adParamInput, 50, [put
value here])
.parameters.app end param
set param = .createparamete r("@lname", adVarWChar, adParamInput, 50, [put
value here])
.parameters.app end param
set param = .createparamete r("@cemail", adVarWChar, adParamInput, 50, [put
value here])
.parameters.app end param
set param = .createparamete r("@billadd1" , adVarWChar, adParamInput, 50,
[put value here])
.parameters.app end param
set param = .createparamete r("@billadd2" , adVarWChar, adParamInput, 50,
[put value here])
.parameters.app end param
set param = .createparamete r("@billcity" , adVarWChar, adParamInput, 50,
[put value here])
.parameters.app end param
set param = .createparamete r("@billregion" , adVarWChar, adParamInput, 50,
[put value here])
.parameters.app end param
set param = .createparamete r("@billpostcod e", adVarWChar, adParamInput,
50, [put value here])
.parameters.app end param
set param = .createparamete r("@billcountry ", adVarWChar, adParamInput, 50,
[put value here])
.parameters.app end param
set param = .createparamete r("@phone", adVarWChar, adParamInput, 50, [put
value here])
.parameters.app end param
set param = .createparamete r("@deladd1", adVarWChar, adParamInput, 50,
[put value here])
.parameters.app end param
set param = .createparamete r("@deladd2", adVarWChar, adParamInput, 50,
[put value here])
.parameters.app end param
set param = .createparamete r("@scity", adVarWChar, adParamInput, 50, [put
value here])
.parameters.app end param
set param = .createparamete r("@sregion", adVarWChar, adParamInput, 50,
[put value here])
.parameters.app end param
set param = .createparamete r("@spostcode ", adVarWChar, adParamInput, 50,
[put value here])
.parameters.app end param
set param = .createparamete r("@shipcountry ", adVarWChar, adParamInput, 50,
[put value here])
.parameters.app end param
set param = .createparamete r("@special", adVarWChar, adParamInput, 200,
[put value here])
.parameters.app end param
set param = .createparamete r("@Ident", adInteger, adParamInputOut put, 0,
[put value here])
.parameters.app end param
.execute ,,adexecutenore cords
end with

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

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

Similar topics

134
7950
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 means that if I misspell a variable name, my program will mysteriously fail to work with no error message. If you don't declare variables, you can inadvertently re-use an variable used in an enclosing context when you don't intend to, or
7
1586
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 would like to have an application where I would write the core and the users could write
7
2173
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 got is a decodeImage.aspx page that gets called to decode base64 encoded images and return them as displayable images to a Web page. The ASPX page is passed two parameters, "file" and "img". The "file" parameter specifies and XML file on the Web...
4
1193
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 test I have built a class that sets up a wrapper around the SmtpMail object so that with only a couple of statements an email can
2
3529
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: Provider=Microsoft.Jet.OLEDB.4.0;Data
9
2993
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 ... - preload the .net 2 framework (windows startup or whatever) - splash a screen ... application loading ... please wait ... type of
9
4556
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 TypeOf obj Is IDisposable Then DirectCast(obj, IDisposable).Dispose()
0
2539
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. I created a project and added the following references - 1/ Enterprise Library Exception Handling Application Block v 4.0
4
7674
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
9899
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9750
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11024
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10740
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10362
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9510
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5738
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3182
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.