Solved

Sybase ODBC driver supporting Nchar

Posted on 2004-08-18
8
458 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
Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
In this blog we highlight approaches to managed security as a service.  We also look into ConnectWise’s value in aiding MSPs’ security management and indicate why critical alerting is a necessary integration.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

707 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