#include "MySQL.au3"
#include <Array.au3>
__MySQL_ExtractEmbeddedDLL()
_MySQL_InitLibrary()
If @error Then Exit MsgBox(0, '', "could nit init MySQL")
Global $MysqlConn = _MySQL_Init()
Database()
_MySQL_Close($MysqlConn)
_MySQL_EndLibrary()
Func DATABASE()
$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)
_MySQL_Close($MysqlConn)
_MySQL_EndLibrary()
Exit
EndIf
_MySQL_Set_Character_Set($MysqlConn, "GBK")
_MySQL_Real_Query($MysqlConn, "CREATE DATABASE IF NOT EXISTS test DEFAULT CHARSET gbk")
_MySQL_Real_Query($MysqlConn, "use w87130;")
Local $timedate = "now()"
Local $my = "00:F0:00:FF:00:FF"
Local $Name = "testname"
Local $IDname = "s448920"
Local $User = "右地震荡"
Local $code = "11111"
Local $alltest = "PASS"
Local $time1 = "232"
Local $time2 = "234"
$sMySqlStatement = "CREATE TABLE IF NOT EXISTS test (" & _
"TimeDate TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," & _
"Name TEXT NOT NULL ," & _
"My TEXT NOT NULL," & _
"IDname TEXT NOT NULL ," & _
"User TEXT NOT NULL ," & _
"Code TEXT NOT NULL ," & _
"Result TEXT NOT NULL ," & _
"Time1 TEXT NOT NULL ," & _
"Time2 TEXT NOT NULL );"
If _MySQL_Real_Query($MysqlConn, $sMySqlStatement, StringLen($sMySqlStatement) * 2) <> $MYSQL_SUCCESS Then
ConsoleWrite("Error: " & _MySQL_errno($MysqlConn) & " " & _MySQL_error($MysqlConn) & @LF)
Return
EndIf
Local $sMySqlStatement = "INSERT INTO test (TimeDate,Name,My,IDname," & _
"User,Code,Result,Time1,Time2) VALUES (NOW()," & _
"'" & $my & "'," & _
"'" & $Name & "'," & _
"'" & $IDname & "'," & _
"'" & $User & "'," & _
"'" & $code & "'," & _
"'" & $alltest & "'," & _
"'" & $time1 & "'," & _
"'" & $time2 & "');"
ConsoleWrite("$sMySqlStatement " & $sMySqlStatement & @LF)
If _MySQL_Real_Query($MysqlConn, $sMySqlStatement, StringLen($sMySqlStatement) * 2) <> $MYSQL_SUCCESS Then
ConsoleWrite("error: " & _MySQL_errno($MysqlConn) & " " & _MySQL_error($MysqlConn) & @LF)
MsgBox(16, "error: " & _MySQL_errno($MysqlConn), _MySQL_error($MysqlConn))
Return
Else
MsgBox(64, "恭喜!", "写数据到数据库OK!")
EndIf
EndFunc ;==>DATABASE
以上代码本地mysql可以 购买的mysql服务器就10060了。