Solved

adVarWChar doesnt work for nvarchar

Posted on 2007-03-21
3
2,461 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
ID: 18763755
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
ID: 18764793
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
ID: 18768777
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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/…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

863 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

23 Experts available now in Live!

Get 1:1 Help Now