本帖最后由 chzj589 于 2019-6-27 12:28 编辑
我刚发现是你的数据库的后缀问题:$adSource = @ScriptDir & "\DB1.mdb";DB1.accdb"
#AutoIt3Wrapper_UseX64 = n
$adSource = @ScriptDir & "\DB1.mdb";DB1.accdb"
$Password = "123456"
$adtables = "admin"
If Not FileExists($adSource) Then;如果脚本所在目录没有发现数据库文件,则创建数据库文件,
$newMdb = ObjCreate("ADOX.Catalog")
$newMdb.Create("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & $adSource & ";Jet Oledb:Database Password=" & $Password);创建新的目录
$newMdb.ActiveConnection.Close
$ADDTBL = ObjCreate("ADODB.Connection")
$ADDTBL.Open("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & $adSource & ";Jet Oledb:Database Password=" & $Password)
$ADDTBL.Execute("CREATE TABLE " & $adtables)
$ADDTBL.Close;建表
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & $adSource & ";Jet Oledb:Database Password=" & $Password)
$addfld.Execute("ALTER TABLE " & $adtables & " ADD id identity(1, 1) primary key,namekey text(255),passkey text(255) ,ipasskey text(255),ipasskeya text(255),ipasskeyb text(255))")
$addfld.close
$namekey = "A"
$passkey = "B"
$ipasskey = "C"
$ipasskeya = "D";@YEAR & "年" & @MON & "月" & @MDAY & "日";"zxc-=iop"
$ipasskeyb = "未注册"
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & $adSource & ";Jet Oledb:Database Password=" & $Password)
$addfld.execute("insert into " & $adtables & " (namekey,passkey,ipasskey,ipasskeya,ipasskeyb) values('" & $namekey & "','" & $passkey & "','" & $ipasskey & "','" & $ipasskeya & "','" & $ipasskeyb & "')")
$addfld.close
MsgBox(64, "提示", "建立数据库成功", 1)
Else
MsgBox(64, "提示", "你已经建立了一个数据库了", 1)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & $adSource & ";Jet Oledb:Database Password=" & $Password)
$RS = ObjCreate("ADODB.recordset")
$RS.ActiveConnection = $addfld
$RS.open("SELECT * FROM " & $adtables)
Local $i = 0
While Not $RS.eof And Not $RS.bof
MsgBox(0, "提示", $RS.Fields(1).value & @CRLF & $RS.Fields(2).value & @CRLF & $RS.Fields(3).value & @CRLF & $RS.Fields(4).value & @CRLF & $RS.Fields(5).value, 5)
;$i += 1
$RS.movenext
WEnd
$RS.close
$addfld.Close
EndIf
|