首页 > 数据库 > SQL Server > 正文

通过 OLE DB 连接 MSSQL Server时出现乱码的解决方法

2024-08-31 00:48:07
字体:
来源:转载
供稿:网友
当使用ole db方式与ms sql server连接时,如果数据库的代码页与本地的不同,当进行查询时字符的返回值就会变成 ? 或是乱码, 微软的网站上说这是一个bug, 并且描述如下:
when you try to retrieve character data from a column with different collation than the client code page in microsoft sql ole db provider (sqloledb), you may receive question marks (??) instead of correct data when all the following conditions are true:
•a connection is made against a microsoft sql server 2000 database.
•ssprop_init_autotranslate is set to true. ssprop_init_autotranslate is part of the provider-specific dbpropset_sqlserverdbinit property set.
•a column is bound to an oledb dbtype_wchar data type in the bindings structure.

我的解决方法是关掉 自动字符转换. 例子如下:(powerbuilder 中)
sqlca.dbms = 'ole db'
sqlca.logid = 'sa'
sqlca.logpass = ''
sqlca.dbparm = “provider='sqloledb', datasource='my-server', commitondisconnect='no', providerstring='database=mydb, autotranslate=no'”

最大的网站源码资源下载站,

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表