Public Sub NewScript(td As TriggerData)
On Error GoTo ErrHandler
' TODO: Add your code here
MsgBox ("Hi world")
Dim dbcon As New ADODB.Connection
' Set rs = CreateObject("ADODB.Recordset")
Dim dbname As String
Dim servername As String
Dim userid As String
Dim pwd As String
Dim strSql As String
servername = "localhost"
dbname = "world"
userid = "root"
pwd = "admin123"
Set dbcon = New ADODB.Connection
dbcon.ConnectionString = "DRIVER={MySQL ODBC 5.3 ANSI Driver}" _
& ";SERVER=" & servername _
& ";DATABASE=" & dbname _
& ";UID=" & userid _
& ";PWD=" & pwd _
& ";Option=3"
dbcon.Open
MsgBox "connection open"
If dbcon.State = ADODB.adStateOpen Then
MsgBox "connection success"
dbcon.CursorLocation = adUseClient
Else
MsgBox "connection fail"
dbcon.Close
Set dbcon = Nothing
Exit Sub
End If
数据库连接线后... msgbox“连接打开”未执行