链接正常,但运行到(cmd).Execute时提示错误:
“运行错误 '-2147217900 (80040e14)':
[MySQL][ODBC 3.51 Driver][mysqld-5.5.12]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'source c:/ok.txt' at line 1”通过Command能运行“use db;”命令,却不能执行“source c:/ok.txt;”。
请问有什么解决方法?请高手指点。部分Visual Basic代码: Dim Conn As ADODB.Connection
Dim Rec As ADODB.Recordset
Dim Cmd As ADODB.Command
Dim i As Integer
Application.ScreenUpdating = False
Set Conn = New ADODB.Connection
Conn.ConnectionString = "Driver={MySQL ODBC 3.51 Driver};" + _
"Server=localhost;Stmt=Set Names 'GBK';" + _
"UID=monty;" + _
"PWD=123456;" + _
"" + _
"Option=16384;"
Conn.Open
Set Cmd = New ADODB.Command
Conn.Errors.Clear: Err.Clear
Conn.BeginTrans
With Cmd
.ActiveConnection = Conn
.CommandType = adCmdText
.CommandText = "source c:/ok.txt;"
.Execute '这里出错!!
End With
Conn.CommitTrans
......
“运行错误 '-2147217900 (80040e14)':
[MySQL][ODBC 3.51 Driver][mysqld-5.5.12]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'source c:/ok.txt' at line 1”通过Command能运行“use db;”命令,却不能执行“source c:/ok.txt;”。
请问有什么解决方法?请高手指点。部分Visual Basic代码: Dim Conn As ADODB.Connection
Dim Rec As ADODB.Recordset
Dim Cmd As ADODB.Command
Dim i As Integer
Application.ScreenUpdating = False
Set Conn = New ADODB.Connection
Conn.ConnectionString = "Driver={MySQL ODBC 3.51 Driver};" + _
"Server=localhost;Stmt=Set Names 'GBK';" + _
"UID=monty;" + _
"PWD=123456;" + _
"" + _
"Option=16384;"
Conn.Open
Set Cmd = New ADODB.Command
Conn.Errors.Clear: Err.Clear
Conn.BeginTrans
With Cmd
.ActiveConnection = Conn
.CommandType = adCmdText
.CommandText = "source c:/ok.txt;"
.Execute '这里出错!!
End With
Conn.CommitTrans
......
OR
MYSQL -U -P<123.SQL