代码拉取完成,页面将自动刷新
[General]
SyntaxVersion=2
BeginHotkey=121
BeginHotkeyMod=0
PauseHotkey=0
PauseHotkeyMod=0
StopHotkey=123
StopHotkeyMod=0
RunOnce=1
EnableWindow=
MacroID=b5e29d29-aa9e-4a29-9419-cbc8fd7dd3fc
Description=连接MySQL
Enable=1
AutoRun=0
[Repeat]
Type=0
Number=1
[SetupUI]
Type=2
QUI=
[Relative]
SetupOCXFile=
[Comment]
[Script]
Set connection = CreateObject("ADODB.Connection")
//connection.Open "DSN=Mysql;UID=root;PWD=123456;PORT=3306;DATABASE=testdb;Data Source=localhost"
connection.Open "Provider=MSDASQL.1;Password=123456;Persist Security Info=True;User ID=root;Data Source=localhost;Initial Catalog=testdb"
Set recordset = CreateObject("ADODB.Recordset")
connection.BeginTrans
SQL1 = "DELETE FROM items WHERE id = 1"
connection.Execute SQL1, resLength1
TracePrint resLength1
SQL2 = "UPDATE items SET name = '龙纹剑', price = 777 WHERE id = 2"
connection.Execute SQL2, resLength2
TracePrint resLength2
SQL3 = "INSERT INTO items(name, price) VALUES('屠龙刀', '999')"
connection.Execute SQL3, resLength3
TracePrint resLength3
TracePrint connection.Errors.Count
If connection.Errors.Count > 0 Then
connection.RollbackTrans
Else
connection.CommitTrans
End If
SQL = "SELECT * FROM items"
recordset.open SQL, connection, 1
If recordset.bof And recordset.eof Then
TracePrint "没有记录"
Else
While not recordset.eof
TracePrint recordset("id") & " " & recordset("name") & " " & recordset("price")
recordset.movenext
Wend
End If
recordset.close
connection.close
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。