我在某公司申请了个mysql,查询时正常,插入数据就失败了。包括建表等。
我把代码以及数据库登录信息都贴出来,麻烦高手帮忙看看:#include <Array.au3>
#include "mysql.au3"
Database("测试用户","123456","BFEBFBFF000006F65VM06J47",@YEAR&"-"&@MON&"-"&@WDAY,@YEAR+1&"-"&@MON&"-"&@WDAY)
Func DATABASE($name,$pass,$mcode,$startdate,$enddate)
__MySQL_ExtractEmbeddedDLL()
_MySQL_InitLibrary()
If @error Then Exit MsgBox(16,"错误","MySQL初始化失败!")
$MysqlConn=_MySQL_Init()
$connected=_MySQL_Real_Connect($MysqlConn,"222.73.26.222","sq_dbtest","123456","sq_dbtest")
If $connected=0 Then
$errno = _MySQL_errno($MysqlConn)
MsgBox(16,"错误",$errno&@LF&_MySQL_error($MysqlConn))
If $errno=$CR_UNKNOWN_HOST Then MsgBox(16,"错误","$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 sq_dbtest default charset gbk")
_MySQL_Real_Query($MysqlConn, "use sq_dbtest;")
$sMySqlStatement="create table if not exists member (" & _
"name varchar(10)," & _
"pass varchar(20)," & _
"mcode varchar(50)," & _
"startdate date," & _
"enddate date);"
If _MySQL_Real_Query($MysqlConn, $sMySqlStatement,StringLen($sMySqlStatement)*2)<>$MYSQL_SUCCESS Then
msgbox(16,"错误","建表失败!")
Return
endif
$sMySqlStatement="insert into member VALUES ('"&$name&"','"&$pass&"','"&$mcode&"','"&$startdate&"','"&$enddate&"');"
If _MySQL_Real_Query($MysqlConn,$sMySqlStatement,StringLen($sMySqlStatement)*2)<>$MYSQL_SUCCESS Then
MsgBox(16,"错误" & _MySQL_errno($MysqlConn), _MySQL_error($MysqlConn))
Return
Else
MsgBox(64, "恭喜!", "写数据到数据库OK!")
EndIf
_MySQL_Close($MysqlConn)
_MySQL_EndLibrary()
EndFunc
|