Solved

Sybase ODBC driver supporting Nchar

Posted on 2004-08-18
8
434 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
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!

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

If you thought ransomware was bad, think again! Doxware has the potential to be even more damaging.
February 24, 2017 — On February 23, Travis Ormandy, a vulnerability researcher at Google, reported on Twitter (https://twitter.com/taviso/status/834900838837411840) that massive stores of data have been leaked by CloudFlare, a company that provide…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

778 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