来自MS ACCESS 2007的非英语字符串红色变成了凌乱的代码 [英] NON-english string red from MS ACCESS 2007 becomes messy code

查看:66
本文介绍了来自MS ACCESS 2007的非英语字符串红色变成了凌乱的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dears



我的VB.NET项目通过OleDbConnection连接MS ACCESS 2007,连接字符串如下

Provider = Microsoft.Ace .OleDB.12.0;数据源= D:\ My Documents \Office宏可信位置\ DOMTS.accdb;

读取OleDb.OleDbDataReader的字段

读取字符串的代码片段如下所示

 cmd.CommandText =  选择BLNO,SUM(WT)AS [T_WT],SUM(VOL)AS [T_VOL],NPOD,CCD FROM QueryNotify其中[InSVVD.SVVD] =' + ComboBoxIn.Text +  '和[OutSVVD.FULL] =' + ComboBoxOut.Text +  'GROUP BY BLNO,NPOD,CCD 
' cmd是OleDb.OleDbCommand
dr = cmd.ExecuteReader
' 博士是O. leDb.OleDbDataReader
dr.Read
DirectCast (EXWS.Cells(intActRowNO + intROW_Detl,intActColNO),Excel.Range).Value = intBL_COUNT
DirectCast (EXWS.Cells(intActRowNO + intROW_Detl,intActColNO + 1 ),Excel.Range).Value = dr.Item( BLNO
DirectCast (EXWS.Cells(intActRowNO + intROW_Detl) ,intActColNO + 5 ),Excel.Range).Value = dr.Item( T_WT
如果 dr.Item( T_VOL)> 0 然后
DirectCast ( EXWS.Cells(intActRowNO + intROW_Detl,intActColNO + 6 ),Excel.Range).Value = dr.Item( T_VOL
结束 如果
MsgBox(dr.Item( CCD))
' 在分配到MS Excel范围之前显示数据库中的红色字符串,但显示的是杂乱的代码
DirectCast (EXWS.Cells(intActRowNO + intROW_Detl,intActColNO + 7 ),Excel.Range)。 Value = dr.Item( CCD
DirectCast (EXWS.Cells(intActRowNO + i ntROW_Detl,intActColNO + 8 ),Excel.Range).Value = dr.Item( NPOD

Dim cmd2 As OleDb.OleDbCommand
Dim dr2 作为 OleDb.OleDbDataReader
cmd2.Connection = conDOMTS
cmd2.CommandText = 从QueryNotify中选择CTNNO,CTNTYPE,SEALNO,其中BLNO =' + dr.Item( BLNO )+ '
dr2 = cmd2.ExecuteReader
while dr2.Read
DirectCast (EXWS.Cells(intActRowNO + intROW_Detl,intActColNO + 2 ),Excel.Range).Value = dr2.Item( CTNNO
DirectCast (EXWS.Cells(intActRowNO + intROW_Detl,intActColNO + 3 ),Excel.Range ).Value = dr2.Item( CTNTYPE
DirectCast (EXWS.Cells(intActRowNO + intROW_Detl,intActColNO + 4 ),Excel.Range).Value = dr2.Item( SEALNO
intROW_Detl = intROW_Detl + 1
结束
dr2.Close()
intBL_COUNT = intBL_COUNT + 1
循环





从以下陈述中提出的问题

 MsgBox(dr.Item(  CCD))
' 在分配到MS Excel范围之前显示来自数据库的红色字符串,但是代码混乱显示,也是Excel中显示的杂乱代码
DirectCast (EXWS.Cells(intActRowNO + intROW_Detl,intActColNO + 7 ),Excel.Range).Value = dr.Item( CCD





CCD是MS ACCESS 2007中的备忘录字段。如果我直接打开数据库文件来检查提交的文件,我可以看到所有字符都用正确的中文显示。



代码可以前天正确显示中文,我没有对我的代码进行任何更改数据库,但昨天,运行良好的代码开始出现问题。有人可以帮忙指导如何解决它吗?



我尝试过:



已尝试将连接字符串更改为

Provider = Microsoft.Ace.OleDB.12.0;数据源= D:\ My Documents \Office宏可信位置\ DOMTS.accdb ; CHARSET = utf8

但由于找不到可安装的ISAM

解决方案

抛出的错误找不到可安装的ISAM 错误消息是错误的编译指令。您必须将目标平台更改为与当前安装的Office版本相对应的平台( x86 x64



另一个原因是,OLEDB驱动程序未安装在目标操作系统上。您必须从Microsoft官方下载中心下载并安装Microsoft Access数据库引擎2010可再发行组件 [ ^ ]


请参阅 https://support.microsoft.com/en-gb/kb / 209805 [ ^ ]。

Dears

My VB.NET project connects MS ACCESS 2007 by OleDbConnection,connection string as below
"Provider=Microsoft.Ace.OleDB.12.0;Data Source=D:\My Documents\Office Macro Trusted Location\DOMTS.accdb;"
reads fields by OleDb.OleDbDataReader
The code snippet which reads string is as below

cmd.CommandText = "select BLNO,SUM(WT) AS [T_WT],SUM(VOL) AS [T_VOL],NPOD,CCD FROM QueryNotify where [InSVVD.SVVD]='" + ComboBoxIn.Text + "' and [OutSVVD.FULL]='" + ComboBoxOut.Text + "' GROUP BY BLNO,NPOD,CCD"
'cmd is a OleDb.OleDbCommand
dr = cmd.ExecuteReader
'dr is OleDb.OleDbDataReader
Do While dr.Read
    DirectCast(EXWS.Cells(intActRowNO + intROW_Detl, intActColNO), Excel.Range).Value = intBL_COUNT
    DirectCast(EXWS.Cells(intActRowNO + intROW_Detl, intActColNO + 1), Excel.Range).Value = dr.Item("BLNO")
    DirectCast(EXWS.Cells(intActRowNO + intROW_Detl, intActColNO + 5), Excel.Range).Value = dr.Item("T_WT")
    If dr.Item("T_VOL") > 0 Then
        DirectCast(EXWS.Cells(intActRowNO + intROW_Detl, intActColNO + 6), Excel.Range).Value = dr.Item("T_VOL")
    End If
    MsgBox(dr.Item("CCD"))
    'To show the string red from database before assinged to MS Excel range, but messy code shown
    DirectCast(EXWS.Cells(intActRowNO + intROW_Detl, intActColNO + 7), Excel.Range).Value = dr.Item("CCD")
    DirectCast(EXWS.Cells(intActRowNO + intROW_Detl, intActColNO + 8), Excel.Range).Value = dr.Item("NPOD")

    Dim cmd2 As New OleDb.OleDbCommand
    Dim dr2 As OleDb.OleDbDataReader
    cmd2.Connection = conDOMTS
    cmd2.CommandText = "select CTNNO,CTNTYPE,SEALNO from QueryNotify where BLNO='" + dr.Item("BLNO") + "'"
    dr2 = cmd2.ExecuteReader
    While dr2.Read
        DirectCast(EXWS.Cells(intActRowNO + intROW_Detl, intActColNO + 2), Excel.Range).Value = dr2.Item("CTNNO")
        DirectCast(EXWS.Cells(intActRowNO + intROW_Detl, intActColNO + 3), Excel.Range).Value = dr2.Item("CTNTYPE")
        DirectCast(EXWS.Cells(intActRowNO + intROW_Detl, intActColNO + 4), Excel.Range).Value = dr2.Item("SEALNO")
        intROW_Detl = intROW_Detl + 1
    End While
    dr2.Close()
    intBL_COUNT = intBL_COUNT + 1
Loop



The problem raised from the below statments

MsgBox(dr.Item("CCD"))
'To show the string red from database before assinged to MS Excel range, but messy code shown,also messy code shown in Excel
DirectCast(EXWS.Cells(intActRowNO + intROW_Detl, intActColNO + 7), Excel.Range).Value = dr.Item("CCD")



CCD is a memo field in MS ACCESS 2007. If I open the database file directly to check the filed, I can see all characters are shown in correct Chinese.

The code can show Chinese corretly the day before yesterday, I didn't make any change to my code and database,but yesterday, the well-running code started to be in problem. Can someone help to guide how to fix it?

What I have tried:

Have tried to change connction string to
"Provider=Microsoft.Ace.OleDB.12.0;Data Source=D:\My Documents\Office Macro Trusted Location\DOMTS.accdb;CHARSET=utf8"
but an error thrown as Could not find installable ISAM

解决方案

The most common reason of Could not find installable ISAM error message is bad compilation instruction. You have to change Target platform to platform which corresponding to currently installed Office version (x86 or x64)

Another reason is that, that OLEDB drivers aren't installed on destination OS. You have to download and install Microsoft Access Database Engine 2010 Redistributable from Official Microsoft Download Center[^]


See https://support.microsoft.com/en-gb/kb/209805[^].


这篇关于来自MS ACCESS 2007的非英语字符串红色变成了凌乱的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆