Solved

adVarWChar doesnt work for nvarchar

Posted on 2007-03-21
3
2,450 Views
Last Modified: 2008-01-09
Hi experts,

One field in my table is set as nvarchar for keeping unicode stuff.  I find my ASP page 's not working smooth. Here are my StoredProc and ASP.

My Stored Proc
-------------------
@ChineseName nvarchar(50),
@StaffExpDate varchar(10)

My ASP
-------------------
Set objParam = .Parameters
objParam.Append .CreateParameter("@ChineseName", adVarWChar, adParamInput, 50, strChineseName)
objParam.Append .CreateParameter("@StaffExpDate", adVarChar, adParamInput, 10, dStaffExpDate)

In my SP, for Chinese Name, if I change to varchar(50),
and change my ASP to
objParam.Append .CreateParameter("@ChineseName", adVarChar, adParamInput, 50, strChineseName),
I can update the stuff without any problem.

However, if I stick with that nvarchar in SP, adVarWChar in ASP, it will show the error
Microsoft OLE DB Provider for SQL Server error '80040e07'

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

I m wondering, would adVarWChar really suitable for nvarchar? Or would there be any better options?

Thanks,
Manfred


0
Comment
Question by:manfredino
3 Comments
 
LVL 10

Expert Comment

by:lahousden
Comment Utility
What is the character representation of the date that you are passing in to the Stored Procedure?
0
 
LVL 29

Accepted Solution

by:
Nightman earned 50 total points
Comment Utility
adVarWChar is suitable for Chines characters. However, neither nvarchar or varchar are really suitable for dates. You should be using datetime datatype.

As per lahousden's question, what does the data look like that you are passing into the procedure?
0
 

Author Comment

by:manfredino
Comment Utility
adVarWChar works now!

as for the codings previously made , there are several other date fields. In asp, they were set as adVarChar under DD-MM-YYYY format, then in the Stored Proc, dates with DD-MM-YYYY format would be converted like select @tmpChgEndDate=convert(datetime,substring(@ChgEndDate,4,2)+'-'+substring(@ChgEndDate,1,2)+'-'+substring(@ChgEndDate,7,4)) to make it as DD/MM/YYYY

Thanks a lot lahousden & Nightman! Thanks for your advices!
 
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now