请指教---数据库查询后的数据如何填充GUI input
请指教如下代码何如实现数据库查询后的数据填充进INPUT里面,感激不尽#include <EditConstants.au3>#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("会员积分查询 v1.0 by jeric", 623, 442, 192, 124)
$Label1 = GUICtrlCreateLabel("***超市---会员积分查询",100, 10, 500, 50)
GUICtrlSetFont(-1, 24, 800, 0, "微软雅黑")
$Label2 = GUICtrlCreateLabel("请输入会员卡号:", 33, 100, 250, 33)
GUICtrlSetFont(-1, 20, 800, 0, "黑体")
$Label2 = GUICtrlCreateLabel("会员姓名:", 60, 180, 250, 33)
GUICtrlSetFont(-1, 20, 800, 0, "黑体")
$Label2 = GUICtrlCreateLabel("会员卡号:", 60, 230, 250, 33)
GUICtrlSetFont(-1, 20, 800, 0, "黑体")
$Label2 = GUICtrlCreateLabel("可用积分:", 60, 280, 250, 33)
GUICtrlSetFont(-1, 20, 800, 0, "黑体")
$Label2 = GUICtrlCreateLabel("卡状态:", 60, 330, 250, 33)
GUICtrlSetFont(-1, 20, 800, 0, "黑体")
$Input1 = GUICtrlCreateInput("请扫描", 264, 96, 321, 37)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
$Input2 = GUICtrlCreateInput("", 192, 170, 345, 45)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
GUICtrlSetState(-1, $GUI_DISABLE)
$Input3 = GUICtrlCreateInput("", 192, 220, 345, 45)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
GUICtrlSetState(-1, $GUI_DISABLE)
$Input4 = GUICtrlCreateInput("", 192, 270, 345, 45)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
GUICtrlSetState(-1, $GUI_DISABLE)
$Input5 = GUICtrlCreateInput("", 192, 320, 345, 45)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
GUICtrlSetState(-1, $GUI_DISABLE)
$Button1 = GUICtrlCreateButton("查询", 268, 376, 95, 35)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xC0DCC0)
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Dim $Input1=1,$Input2=1,$Input3=1,$Input4=1,$Input5=1
Dim $AccelKeys = [["{Enter}", $Button1]]
GUISetAccelerators($AccelKeys)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
MsgBox(0, "", "Tool was closed")
Exit
Case ;$Button1;读取
If ControlGetFocus($Form1) = 'Edit1' Then find()
EndSwitch
WEnd
Func find()
$Strn = GUICtrlRead($Input1)
$conn = ObjCreate( "ADODB.Connection" )
$DSN = "DRIVER={SQL Server};SERVER="ip地址";DATABASE="数据库名称";UID=sa;PWD="密码";"
;数据库连接
$conn.Open($DSN)
$rs = ObjCreate( "ADODB.RecordSet" )
$rs.Open( "select memname,cardid,point2,status from v_mem_card where cardid = '"& $Strn &"'", $conn )
While Not $RS.eof And Not $RS.bof
If @error = 1 Then ExitLoop
;MsgBox(0, "", $RS.Fields($i).value);显示表第一个数据
For $i=0 To $rs.Fields.count-1
Switch $rs.Fields($i).name
Case "memname"
GUICtrlSetData ($Input2,$RS.Fields($i).value)
Case "cardid"
GUICtrlSetData ($Input3,$RS.Fields($i).value)
Case "point2"
GUICtrlSetData ($Input4,$RS.Fields($i).value)
Case "status"
If $rs.Fields($i).value == "4" Then;数字翻译成汉字的例子
GUICtrlSetData ($Input5,"作废")
Else
GUICtrlSetData ($Input5,$RS.Fields($i).value)
EndIf
EndSwitch
Next
$RS.movenext
WEnd
$RS.close
$conn.close
GUICtrlSetData ($Input1,"")
EndFunc ;==>find
页:
[1]