本帖最后由 maker 于 2011-12-10 13:13 编辑
请教各位前辈,为什么会出错,怎么处理这样的情况?
出错原因:
如果数据中含有某一类的特殊字符,就会报错,如:道道ヴ冷酷到底,如果把其中的“ヴ”去掉的话就不会报错了,请各位高人赐教如何处理,谢谢
错误如图:
测试代码:Dim $caiw_path = @ScriptDir & '\aaa.mdb',$mdb_data_pwd='',$tblname='aaa'
data()
cha_jl_MDB()
Func cha_jl_MDB()
$addfld = ObjCreate("ADODB.Connection")
$addfld.open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $caiw_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.open("Select * From " & $tblname & " where jues like '%星%'")
While Not $RS.eof And Not $RS.bof
If @error = 1 Then ExitLoop
$re = $RS.Fields(0).value
$re &= '|' & $RS.Fields(1).value
MsgBox(0,0,$re)
$RS.movenext
WEnd
$RS.close
$addfld.Close
EndFunc ;==>cha_jl_MDB
Func data()
If Not FileExists($caiw_path) Then
$newMdb = ObjCreate("ADOX.Catalog")
$newMdb.Create("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $caiw_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$newMdb.ActiveConnection.Close;建数据库
$addtbl = ObjCreate("ADODB.Connection")
$addtbl.open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $caiw_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$addtbl.Execute("CREATE TABLE " & $tblname)
$addtbl.Close;建表
$addfld = ObjCreate("ADODB.Connection")
$addfld.open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $caiw_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$addfld.Execute("ALTER TABLE " & $tblname & " ADD xu identity(1, 1) primary key,jues varchar")
$addfld.Close;建列表名
TrayTip('完成', '本月数据库', 3)
EndIf
EndFunc ;==>data
|