通过OLEDB连接MS时出现乱码的解决方法

<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
当使用OLEDB方式与MSSQLServer连接时,如果的代码页与本地的不同,当进行查询时字符的返回值就会变成?或是乱码,微软的上说这是一个BUG,并且描述如下:
WhenyoutrytoretrievecharacterdatafromacolumnwithdifferentcollationthantheclientcodepageinMicrosoftSQLOLEDBProvider(SQLOLEDB),youmayreceivequestionmarks(??)insteadofcorrectdatawhenallthefollowingconditionsaretrue:
•AconnectionismadeagainstaMicrosoftSQLServer2000database.
•SSPROP_INIT_AUTOTRANSLATEissettoTRUE.SSPROP_INIT_AUTOTRANSLATEispartoftheprovider-specificDBPROPSET_SQLSERVERDBINITpropertyset.
•AcolumnisboundtoanOLEDBDBTYPE_WCHARdatatypeinthebindingsstructure.

我的解决方法是关掉自动字符转换.例子如下:(中)
SQLCA.DBMS='OLEDB'
SQLCA.LogID='sa'
SQLCA.LogPass=''
SQLCA.DBParm=“PROVIDER='SQLOLEDB',DataSource='my-server',CommitOnDisconnect='no',ProviderString='Database=mydb,AutoTranslate=no'” <script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
阅读更多
文章标签: database 微软
个人分类: 数据库
想对作者说点什么? 我来说一句

SecureCRT等连接Linux出现乱码

2011年06月24日 3KB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭