Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

adVarWChar doesnt work for nvarchar

Posted on 2007-03-21
3
2,475 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

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 article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

765 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