本帖最后由 kk_lee69 于 2011-11-22 00:10 编辑
回复 17# amxi
語法幫你修正好了......
你用太多的 開
$conn=objcreate("ADODB.Connection")
$rs=ObjCreate("ADODB.Recordset")
$conn.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_name & ";Jet Oledb:Database Password=" & $mdb_pwd)
$rs.Activeconnection=$conn
也用了太多的 關
$conn.close
整個資料庫 每做一件事情 就開關一次 不會太累嗎??
整個程式 開 跟 關 只需要一次...... 你可以看看我的寫法.....你之前有太多的關 你沒清除乾淨當然不能把 開 取消
程式 一進去 開資料庫......其他的用RS 下去作業就好 退出的時候 把資料庫關上就可以了 下面是我修正後的語法
加油 還有很多地方要改 我大概知道你想做啥了 呵呵.............
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author: myName
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <windowsconstants.au3>
#include <comboconstants.au3>
$nm="品名"
$nm1="价格"
$mdb_path=""
$mdb_name="da.mdb"
$mdb_pwd=""
;$mdb_table_name="MyPC"
$mdb_cpu_table="CPU"
$mdb_hdd_table="HDD"
$mdb_mb_table="主板"
$mdb_nc_table="内存"
$mdb_Graphic_table="Graphic"
$mdb_XSQ_table="显示器"
$star="*"
$nform=guicreate("price list of inner market",500,500)
;$ListView1 = GUICtrlCreateListView(" 品名 | 价格 | 日期 ", 188, 10, 100, 100)
$nCPU=GUICtrlCreateLabel(" CPU",6,50,50,20)
$CPU_comb=GUICtrlCreateCombo(" CPU",60,50,160,20)
$cpu_price=GUICtrlCreateEdit(" ",230,50,80,20)
$nMB=GUICtrlCreateLabel(" 主板 ",6,80,50,20)
$MB_comb=GUICtrlCreateCombo(" 主板 ",60,80,160,20)
$mb_price=GUICtrlCreateEdit(" ",230,80,80,20)
$nRaM=GUICtrlCreateLabel(" 内存 ",6,110,50,20)
$Ram_comb=GUICtrlCreateCombo(" 内存",60,110,160,20)
$Ram_price=GUICtrlCreateEdit(" ",230,110,80,20)
$nHDD=GUICtrlCreateLabel(" 硬盘 ",6,140,50,20)
$HDD_comb=GUICtrlCreateCombo(" ",60,140,160,20)
$HDD_price=GUICtrlCreateEdit(" ",230,140,80,20)
$nGraphic=GUICtrlCreateLabel(" 显卡 ",6,170,50,20)
$G_comb=GUICtrlCreateCombo(" 显卡 ",60,170,160,20)
$G_price=GUICtrlCreateEdit(" ",230,170,80,20)
$nCase=GUICtrlCreateLabel(" 机箱 ",6,200,50,20)
$Case_comb=GUICtrlCreateCombo(" 机箱",60,200,160,20)
$Case_price=GUICtrlCreateEdit(" ",230,200,80,20)
$nPower=GUICtrlCreateLabel(" 电源 ",6,230,50,20)
$Power_comb=GUICtrlCreateCombo(" 电源",60,230,160,20)
$Power_price=GUICtrlCreateEdit(" ",230,230,80,20)
$nXSQ=GUICtrlCreateLabel(" 显示器 ",6,260,50,20)
$XSQ_comb=GUICtrlCreateCombo(" 显示器",60,260,160,20)
$XSQ_price=GUICtrlCreateEdit(" ",230,260,80,20)
$nSJ=GUICtrlCreateLabel(" 鼠键套 ",6,290,50,20)
$SJ_comb=GUICtrlCreateCombo("",60,290,120,20)
$SJ_price=GUICtrlCreateEdit(" ",230,290,80,20)
$nYX=GUICtrlCreateLabel(" 音箱 ",6,320,50,20)
$YX_comb=GUICtrlCreateCombo("",60,320,120,20)
$YX_price=GUICtrlCreateEdit(" ",230,320,80,20)
$nDVD=GUICtrlCreateLabel(" 光驱 ",6,350,50,20)
$DVD_comb=GUICtrlCreateCombo("",60,350,120,20)
$DVD_price=GUICtrlCreateEdit(" ",230,350,80,20)
$button1=GUICtrlCreateButton("get price",2,2,50,20)
$Button2 = GUICtrlCreateButton("读取数据", 280, 408, 113, 25, 0)
$conn=objcreate("ADODB.Connection")
$rs=ObjCreate("ADODB.Recordset")
$conn.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_name & ";Jet Oledb:Database Password=" & $mdb_pwd)
$rs.Activeconnection=$conn
_getcpu()
_GetHDD()
GUISetState(@sw_show)
while 1
$msg=GUIGetMsg()
Switch $msg
case $gui_event_close
$conn.close
Exit
case $button1
_getcpu()
case $button2
MsgBox(0,"",@scriptdir&"\da.mdb")
_read()
case $cpu_comb
$type=GUICtrlRead($cpu_comb)
$rs.Open ("Select "&$star &" From "&$mdb_cpu_table& " where name='"&$type&"'")
GUICtrlSetData($cpu_price,$rs.fields(2).value)
$rs.close
EndSwitch
WEnd
func _read()
GUICtrlSendMsg($ListView1, $LVM_DELETEALLITEMS, 0, 0)
$rs.Open ("Select "&$star & " From " &$mdb_cpu_table)
; $RS.Open ("Select "&$T & " From " & $tblname )
while Not $RS.eof And Not $RS.bof
if @error then ExitLoop
;GUICtrlCreateListViewItem ( $RS.Fields (0).value&"|"& $RS.Fields (1).value&"|"& $RS.Fields (2).value,$ListView1 )
GUICtrlCreateListViewItem( $rs.fields(1).value&"|"& $rs.fields(2).value ,$listview1)
$rs.movenext
WEnd
$rs.close
EndFunc
Func _GetHDD()
$rs.Open ("Select "&$star&" From "&$mdb_HDD_table )
while not $rs.eof and not $rs.bof
if @error then ExitLoop
GUICtrlSetData($hdd_comb,$rs.fields(1).value)
$rs.movenext
WEnd
$rs.close
EndFunc
Func _GetCPU()
$rs.Open ("Select "&$star & " From " &$mdb_cpu_table )
while not $rs.eof and not $rs.bof
if @error then ExitLoop
GUICtrlSetData($cpu_comb,$rs.fields(1).value)
$rs.movenext
WEnd
$rs.close
EndFunc
Func _GetMB()
$rs.Open ("Select "&$star & " From " &$mdb_mb_table )
while not $rs.eof and not $rs.bof
if @error then ExitLoop
GUICtrlSetData($mb_comb,$rs.fields(1).value)
$rs.movenext
WEnd
$rs.close
EndFunc
Func _GetGraphic()
$rs.Open ("Select "&$star & " From " &$mdb_Graphic_table )
while not $rs.eof and not $rs.bof
if @error then ExitLoop
GUICtrlSetData($G_comb,$rs.fields(1).value)
$rs.movenext
WEnd
$rs.close
EndFunc
|