Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

adVarWChar doesnt work for nvarchar

Posted on 2007-03-21
3
Medium Priority
?
2,523 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
[X]
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
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 150 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
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.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

730 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