#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=D:\ico\documents-white-exec.ico
#AutoIt3Wrapper_outfile=C:\Documents and Settings\Administrator\桌面\printf1.exe
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <array.au3>
#include "mysql.au3"
$Form1 = GUICreate("报表查询", 1000, 700, 0, 0)
$Button1 = GUICtrlCreateButton("职员档案", 80, 64, 81, 65)
$Button2 = GUICtrlCreateButton("订单列表", 80, 154, 81, 65)
GUISetState(@SW_SHOW)
While 1
$Msg = GUIGetMsg()
Select
Case $msg = $Button1
_MySQL_InitLibrary()
$MysqlConn = _MySQL_Init()
$connected = _MySQL_Real_Connect($MysqlConn, "localhost", "root", "_Memo", "oaerp_e2dx500i9erp1262745042");(,服务器名,ID,密码,数据库名)
If $connected = 0 Then Exit MsgBox(16, 'Connection Error', _MySQL_Error($MysqlConn))
_mysql_set_character_set($MysqlConn,"GBK")
$query = "SELECT Name FROM HEmployee";需要查询的语句
_MySQL_Real_Query($MysqlConn, $query)
$res = _MySQL_Store_Result($MysqlConn)
$fields = _MySQL_Num_Fields($res)
$rows = _MySQL_Num_Rows($res)
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)
_MySQL_Data_Seek($res, 0)
_MySQL_Free_Result($res)
_MySQL_Close($MysqlConn)
_MySQL_EndLibrary()
Case $msg = $Button2
_MySQL_InitLibrary()
$MysqlConn = _MySQL_Init()
$connected = _MySQL_Real_Connect($MysqlConn, "localhost", "root", "_Memo", "oaerp_e2dx500i9erp1262745042");(,服务器名,ID,密码,数据库名)
If $connected = 0 Then Exit MsgBox(16, 'Connection Error', _MySQL_Error($MysqlConn))
_mysql_set_character_set($MysqlConn,"GBK")
$query = "SELECT Name FROM tblsalecontr";需要查询的语句2
_MySQL_Real_Query($MysqlConn, $query)
$res = _MySQL_Store_Result($MysqlConn)
$fields = _MySQL_Num_Fields($res)
$rows = _MySQL_Num_Rows($res)
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)
_MySQL_Data_Seek($res, 0)
_MySQL_Free_Result($res)
_MySQL_Close($MysqlConn)
_MySQL_EndLibrary()
Case $msg = $GUI_EVENT_CLOSE
MsgBox(0, "注意", "正在退出...")
ExitLoop
EndSelect
WEnd
昨天下了官方的UDF, 虽然有些是德文,但是连蒙带猜的 测试出来了,高手不要笑话哈