Solved

Sybase ODBC driver supporting Nchar

Posted on 2004-08-18
8
415 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
  • 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

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

Suggested Solutions

Hyena v12.2 is now available for downloading and is available in English, French, German and Spanish versions.
A Short Story about the Best File Recovery Software – Acronis True Image 2017
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 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