昨晚我找<xtybfgu>帮我写的个修改数据库的代码,可是只能读取修改就出错.我把代码和数据库文件发出来,大家帮我看看.
这个是界面.
输入会员后能查找出来.
然后就进行余款修改,改了数字点修改后就出错了.
大家帮我看看这是哪里出了问题...谢谢了.
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$datename="NetBarDB.mdb"
$datepass="chuangyuan+toprenren"
$T="*"
$tblname="tbMember"
#Region ### START Koda GUI section ### Form=C:\Documents and Settings\Administrator\桌面\Form1.kxf
$Form1 = GUICreate("Form1", 344, 152, 351, 301)
$Label1 = GUICtrlCreateLabel("会员卡号:", 16, 24, 55, 17)
$hek=GUICtrlCreateInput("", 96, 24, 153, 21)
$Button1 = GUICtrlCreateButton("查找", 272, 24, 41, 25, 0)
$Label2 = GUICtrlCreateLabel("用户名:", 24, 72, 43, 17)
$textname=GUICtrlCreateInput("", 96, 72, 153, 21)
GUICtrlSetState (-1,$GUI_DISABLE)
$Label3 = GUICtrlCreateLabel("余款", 32, 120, 28, 17)
$textmoney=GUICtrlCreateInput("", 96, 112, 153, 21)
$Button2 = GUICtrlCreateButton("修改", 272, 112, 49, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
case $Button1
du()
case $Button2
up()
EndSwitch
WEnd
Func up()
$Strn=GUICtrlRead($hek)
$cy=GUICtrlRead($textmoney)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datename & ";Jet Oledb:Database Password=" & $datepass)
$sQuery ="update " & $tblname & " set money=" &$cy & " WHERE cardNo" & " = "&$Strn
MsgBox(0,"",$sQuery)
$addfld.execute($sQuery)
$addfld.close
MsgBox(4096, "提示:"," 更新成功!!!")
EndFunc
Func du()
Global $name,$money
$Strn=GUICtrlRead($hek)
$addfld = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datename & ";Jet Oledb:Database Password=" & $datepass)
$RS.ActiveConnection = $addfld
$jy="select * from tbMember where cardNO= '"&$Strn&"'"
$RS.Open ($jy)
if $rs.eof and $rs.bof then
MsgBox(64,"提示","没有这个会员号",5)
GUICtrlSetData ( $hek,"")
ControlFocus ( "", "", $hek)
Else
GUICtrlSetData ( $textname,$RS.Fields (10).value)
GUICtrlSetData ( $textmoney,$RS.Fields (3).value)
EndIf
$rs.close
$addfld.Close
EndFunc
|