Dim conn As New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\ceshi.mdb;Persist Security Info=False"
'打開資料庫連接
conn.Open
Dim Execute As String
Execute = "xxx"
conn.Execute Execute
'關閉資料庫并釋放資料庫物件
conn.Close
Set conn = Nothing
這樣用Insert陳述句保存的字串是UTF-8編碼的,ASP網站打開全是亂碼,怎么解決這樣的問題,找了好多天才找到原因,怎么用GBK的編碼保存字串,在線急求答案
uj5u.com熱心網友回復:
從 Access 2000 開始字串都是 Unicode 的,你可以打開 mdb 看看,里面的內容有沒有亂碼。通過 ADO 讀取的字串也一樣是 Unicode 的,這中間不需要轉碼。
出現亂碼最可能是你 ASP 把字串輸出到頁面時編碼不對。
ASP頁面顯示亂碼解決方法/ASP設定編碼
uj5u.com熱心網友回復:
GBK編碼直接轉是沒有這個命令的
還是改asp編碼簡單點.
如果是UTF-8轉Unicode還是可以的
'Utf8 轉換為 Unicode
Public Function UTF8_Decode(ByVal s As String) As String
Dim lUtf8Size As Long
Dim sBuffer As String
Dim lBufferSize As Long
Dim lResult As Long
Dim b() As Byte
If LenB(s) Then
On Error GoTo EndFunction
b = StrConv(s, vbFromUnicode)
lUtf8Size = UBound(b) + 1
On Error GoTo 0
'Set buffer for longest possible string i.e. each byte is
'ANSI<=&HFF, thus 1 unicode(2 bytes)for every utf-8 character.
lBufferSize = lUtf8Size * 2
sBuffer = String$(lBufferSize, vbNullChar)
'Translate using code page 65001(UTF-8)
lResult = MultiByteToWideChar(CP_UTF8, 0, b(0), _
lUtf8Size, StrPtr(sBuffer), lBufferSize)
'Trim result to actual length
If lResult Then
UTF8_Decode = Left$(sBuffer, lResult)
'Debug.Print UTF8_Decode
End If
End If
EndFunction:
End Function
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/81878.html
上一篇:vb6.0利用ado和mshfelxgrid控制元件匯入excel2003的資料,出現sheet1$不是一個有效的名稱
