#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$mdb_data_path="ACC.mdb"
$mdb_data_pwd=""
$t="*"
$mdb_name="wizard"
data($mdb_data_path, $mdb_name)
$name="某神经"
$guhua="62219213"
$shouji="15785151234"
$dizhi="郑州"
$Form1 = GUICreate("ACC 数据库测试", 490, 214, 282, 269)
$List1 = GUICtrlCreateListView("", 0, 0, 489, 162)
_GUICtrlListView_AddColumn($List1,"名字",100,2)
_GUICtrlListView_AddColumn($List1,"固话",100,2)
_GUICtrlListView_AddColumn($List1,"手机",100,2)
_GUICtrlListView_AddColumn($List1,"地址",200,2)
$Button1 = GUICtrlCreateButton("添加", 24, 168, 105, 41)
$Button2 = GUICtrlCreateButton("删除", 196, 168, 105, 41)
$Button3 = GUICtrlCreateButton("更新", 355, 168, 105, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
add()
Case $Button3
du()
EndSwitch
WEnd
Func du()
GUICtrlSendMsg($List1, $LVM_DeleteALLITEMS, 0, 0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select " & $t & " From " & $mdb_name)
While Not $RS.eof And Not $RS.bof
If @error = 1 Then ExitLoop
GUICtrlCreateListViewItem($RS.fields(1).value & "|" & $RS.fields(2).value & "|" & $RS.fields(3).value & "|" & $RS.fields(4).value, $List1)
$RS.movenext
WEnd
$RS.close
$addfld.Close
EndFunc ;==>du
Func data($mdb_data_path, $mdb_name)
If Not FileExists($mdb_data_path) Then
$newMdb = ObjCreate("ADOX.Catalog")
$newMdb.Create("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$newMdb.ActiveConnection.Close;建数据库
$addtbl = ObjCreate("ADODB.Connection")
$addtbl.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$addtbl.Execute("Create TABLE " & $mdb_name)
$addtbl.Close;建表
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$addfld.Execute("Alter TABLE " & $mdb_name & " ADD id identity(1, 1) primary key,名字 text,固话 text, 手机 text,地址 text");id identity(1, 1) primary key为自动编号和主键
$addfld.Close;建列表名
EndIf
EndFunc ;==>data
Func add()
$Form2 = GUICreate("添加", 264, 134, 473, 199)
$Label1 = GUICtrlCreateLabel("姓名", 10, 8, 36, 25)
GUICtrlSetFont(-1, 12, 400, 0, "微软雅黑")
$Label2 = GUICtrlCreateLabel("固话", 10, 38, 36, 25)
GUICtrlSetFont(-1, 12, 400, 0, "微软雅黑")
$Label3 = GUICtrlCreateLabel("手机", 10, 70, 36, 25)
GUICtrlSetFont(-1, 12, 400, 0, "微软雅黑")
$Label4 = GUICtrlCreateLabel("地址", 10, 102, 36, 25)
GUICtrlSetFont(-1, 12, 400, 0, "微软雅黑")
$Input1 = GUICtrlCreateInput("", 48, 9, 89, 21)
$Input2 = GUICtrlCreateInput("", 48, 41, 89, 21)
$Input3 = GUICtrlCreateInput("", 48, 73, 89, 21)
$Input4 = GUICtrlCreateInput("", 48, 103, 201, 21)
$Button12 = GUICtrlCreateButton("确定", 152, 8, 97, 89)
GUICtrlSetFont(-1, 16, 400, 0, "微软雅黑")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Button12
Local $a,$b,$c,$d
$a=GUICtrlRead($Input1)
$b=GUICtrlRead($Input2)
$c=GUICtrlRead($Input3)
$d=GUICtrlRead($Input4)
sx($a,$b,$c,$d)
EndSwitch
WEnd
GUIDelete($Form2)
EndFunc
Func sx($a,$b,$c,$d)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$x = 0
While 1
$x += 1
If $x > 10 Then ExitLoop
$addfld.Execute("insert into wizard (a,b,c,d) Values('" & $a & "','" & $b & "','" & $c & "','" & $d & "')")
WEnd
$addfld.close
MsgBox(4096, "完毕", "成功写入数")
EndFunc ;==>sx
大家帮忙看下,搞了半天,找不到错误在那里