Solved

Sybase ODBC driver supporting Nchar

Posted on 2004-08-18
8
446 Views
Last Modified: 2012-05-05
Is there an ODBC driver for Sybase Adaptive Server Enterprise 12.0.0.4 for Windows XP that supports the Nchar and Nvarchar data types?
If so, how do I obtain the driver?

I am accessing a Sybase database via ADO using ODBC.  I get an error from my ODBC driver when I attempt to append a command parameter with ADO type adVarWChar.  The same query works when I use ADO type adVarChar.
0
Comment
Question by:Satyabodhi
[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
  • 4
  • 2
8 Comments
 
LVL 29

Expert Comment

by:leonstryker
ID: 11851469
You should be using an OLEDB provider.  it should have come with your install.  Here is the connection string:

http://www.able-consulting.com/MDAC/ADO/Connection/OLEDB_Providers.htm#OLEDBProviderForSybaseAdaptiveServerEnterprise

Leon
0
 
LVL 3

Author Comment

by:Satyabodhi
ID: 11852657
Leon,
We tried an OLEDB provider and it still fails with adVarWChar
Here is the code:
 conn.ConnectionString = "Provider=Sybase.ASEOLEDBProvider.2;Initial Catalog=john;User ID=tester;Password=test06;Data Source=oledbsybase;Persist Security Info=False"

  conn.Open
   cmd.CommandText = "Select * from foo where string = ?"
  cmd.ActiveConnection = conn
  Set p = New Parameter
  p.Value = "One"
'  p.Type = adVarChar
  p.Type = adVarWChar
  p.Direction = adParamInput
  p.Name = "String"
  p.Size = 20
  cmd.Parameters.Append p
  Set rs = cmd.Execute(c)

----- At this point we get the error "The given type name was unrecognized".
The same code succeeds with adVarChar.
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 11852944
Try this:

conn.ConnectionString = "Provider=Sybase.ASEOLEDBProvider.2;Initial Catalog=john;User ID=tester;Password=test06;Data Source=oledbsybase;Persist Security Info=False"
conn.Open

strSQL = "Select * from foo where string = '" & strParam & "'"
rs.Open strSQL, conn, adOpenDynamic, adLockOptimistic
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 29

Expert Comment

by:leonstryker
ID: 11852952
Oops missed one:

conn.ConnectionString = "Provider=Sybase.ASEOLEDBProvider.2;Initial Catalog=john;User ID=tester;Password=test06;Data Source=oledbsybase;Persist Security Info=False"
conn.Open

strParam = "One"

strSQL = "Select * from foo where string = '" & strParam & "'"
rs.Open strSQL, conn, adOpenDynamic, adLockOptimistic
0
 
LVL 3

Author Comment

by:Satyabodhi
ID: 11853132
Yes, that would work, provided we escape all quote characters in the parameter strings (by doubling them).
But, it avoids the initial question of support for adWChar and adVarWChar.
With the solution of NOT using (?) question-mark parameter markers for string parameters you don't need OLEDB.  You can continue with ODBC.
We still need parameter markers, and the command object for date parameters, because we operate in multiple cultural zones.  Most of our queries that use datetime parameters also use string parameters and many use decimal parameters that have similar cultural differences in string representation.

This solution may be the ultimate answer but I am still hoping for something better.
0
 
LVL 29

Accepted Solution

by:
leonstryker earned 125 total points
ID: 11853255
in that case you may want to try this:

strSQL = "Select * from foo where string = N'" & strParam & "'"

Leon
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Facebook has became the #1 social media platform. People share many funny videos there, yet you don't know how to download them? Now you can download Videos from Facebook in just 3 simple steps.
In order to fulfill our mission of inspiring learning in the technology community, Experts Exchange is launching a Course of the Month program. Premium and Team Account members will have access to one course per month as a part of their membership, …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

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