|
本帖最后由 xtanxin 于 2010-1-4 02:01 编辑
在学习AU3在MYSQL的操作时,TEST.AU3代码执行,总是读取数据表的行数总是错误,是该数据类型的上限.好像是4294967296.
打开mysql.AU3文件,我是用_MySQL_Num_Rows出现此错误的.但是真正的问题应该是__MySQL_ReOrderULONGLONG引起的.
这个问题开始始终不得解决,我的电脑重新安装了数个不同版本的WINDOWSSP3 系统,都存在,最后发给2个朋友,台式机没有错误了.读取操作正常.
今天,我用PE进入系统,连接网络,执行test脚本,也出现了同样的错误.
这个是不是一个硬件兼容性的BUG呢?怎么解决呢?
请专家帮帮吧.Func _MySQL_Num_Rows($result)
Local $rows = DllCall("libmysql.dll", "uint64", "mysql_num_rows", "ptr", $result)
If @error Then Return SetError(1, 0, 0)
Return __MySQL_ReOrderULONGLONG($rows[0])
EndFunc ;==>_MySQL_Num_Rows
Func __MySQL_ReOrderULONGLONG($UINT64)
Local $int = DllStructCreate("uint64")
Local $longlong = DllStructCreate("ulong;ulong", DllStructGetPtr($int))
DllStructSetData($int, 1, $UINT64)
Return 4294967296 * DllStructGetData($longlong, 1) + DllStructGetData($longlong, 2)
EndFunc ;==>__MySQL_ReOrderULONGLONG
下面是我用的test.au3,如果哪位能帮忙没有mysql,在下能提供,请联系85111108的QQ#include <array.au3>
#include <mysql.au3>
; MYSQL starten, DLL im PATH (enth鋖t auch @ScriptDir), sont Pfad zur DLL angeben. DLL muss libmysql.dll hei遝n.
_MySQL_InitLibrary()
If @error Then Exit MsgBox(0, '', "")
MsgBox(0, "DLL Version:",_MySQL_Get_Client_Version()&@CRLF& _MySQL_Get_Client_Info())
$MysqlConn = _MySQL_Init()
$connected = _MySQL_Real_Connect($MysqlConn,"ip","账户","密码","数据表名")
If $connected = 0 Then
$errno = _MySQL_errno($MysqlConn)
MsgBox(0,"Error:",$errno & @LF & _MySQL_error($MysqlConn))
If $errno = $CR_UNKNOWN_HOST Then MsgBox(0,"Error:","$CR_UNKNOWN_HOST" & @LF & $CR_UNKNOWN_HOST)
Endif
; XAMPP cdcol
$query = "SELECT * FROM networkadapterinfo"
_MySQL_Real_Query($MysqlConn, $query)
$res = _MySQL_Store_Result($MysqlConn)
$fields = _MySQL_Num_Fields($res)
$rows = _MySQL_Num_Rows($res)
MsgBox(0, "", $rows & "-------------" & $fields) ;显示一下读取表的行列数值,错误就在这里开始的,导致下面显示内容时数组超标
; Zugriff 1
MsgBox(0, '', "Zugriff Methode 1- Handarbeit")
Dim $array[$rows][$fields]
For $k = 1 To $rows
$mysqlrow = _MySQL_Fetch_Row($res,$fields)
$lenthsStruct = _MySQL_Fetch_Lengths($res)
For $i = 1 To $fields
$length = DllStructGetData($lenthsStruct, 1, $i)
$fieldPtr = DllStructGetData($mysqlrow, 1, $i)
$data = DllStructGetData(DllStructCreate("char[" & $length & "]", $fieldPtr), 1)
$array[$k - 1][$i - 1] = $data
Next
Next
_ArrayDisplay($array)
; Zugriff 2
MsgBox(0, '', "Zugriff Methode 2 - Reihe f黵 Reihe")
_MySQL_Data_Seek($res, 0) ; nur zum zum Zur點ksetzen an den Anfang der Abfrage
Do
$row1 = _MySQL_Fetch_Row_StringArray($res)
If @error Then ExitLoop
_ArrayDisplay($row1)
Until @error
MsgBox(0, '', "Zugriff Methode 3 - alles in ein 2D Array")
$array = _MySQL_Fetch_Result_StringArray($res)
_ArrayDisplay($array)
; Feldinformationen
MsgBox(0, '', "Zugriff Feldinformationen")
Dim $arFields[$fields][3]
For $i = 0 To $fields - 1
$field = _MySQL_Fetch_Field_Direct($res, $i)
$arFields[$i][0] = _MySQL_Field_ReadValue($field, "name")
$arFields[$i][1] = _MySQL_Field_ReadValue($field, "table")
$arFields[$i][2] = _MySQL_Field_ReadValue($field, "db")
Next
_ArrayDisplay($arFields)
; Abfrage freigeben
_MySQL_Free_Result($res)
; Verbindung beenden
_MySQL_Close($MysqlConn)
; MYSQL beenden
_MySQL_EndLibrary()
|
|