找回密码
 加入
搜索
查看: 2038|回复: 4

[AU3基础] 关于SQL如何判断查询失败的问题,请大家帮忙。

[复制链接]
发表于 2012-3-3 00:20:07 | 显示全部楼层 |阅读模式
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 378, 190, -1, -1)
$ListView1 = GUICtrlCreateListView("姓名|证件号码|",8, 16, 361, 81)
$Label1 = GUICtrlCreateLabel("编号:", 24, 120, 76, 17)
$Input1 = GUICtrlCreateInput("", 104, 116, 249, 21)
GUICtrlSetLimit(-1, 18,18)
$Button1 = GUICtrlCreateButton("查询", 72, 152, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


$Serverip = IniRead("Member.ini", "SQLServer", "IP","")
$sqlpwd = IniRead("Member.ini", "SQLServer", "PWD","")

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
           if GUICtrlRead($Input1)<>'' Then




        Dim $hardware = "cur_userdetail"
        $conn = ObjCreate("ADODB.Connection")
        $RS = ObjCreate("ADODB.Recordset")
        $conn.Open("driver={SQL Server};server=" & $Serverip & ";uid=netcafe;pwd=" & $sqlpwd & ";database=local")
        $RS.ActiveConnection = $conn
        $RS.open("SELECT * FROM cur_userdetail where uniqueid = '" & GUICtrlRead ( $Input1 ) & "'")
         

        While (Not $RS.eof And Not $RS.bof)
        GUICtrlCreateListViewItem ( $RS.Fields (0).value&"|"& $RS.Fields (3).value,$ListView1 )


        If StringIsDigit($RS.Fields(0).value)=0 Then

         EndIf

        ExitLoop

        WEnd
        $RS.close
               
        Else

                MsgBox(48,'错误','请输入编号查询!')
        EndIf

        EndSwitch
WEnd
没有找到相关数据,,该如何判断,,,       也就是这句   $RS.open("SELECT * FROM cur_userdetail where uniqueid = '" & GUICtrlRead ( $Input1 ) & "'")     查找失败后的返回值 ,怎么判断?
 楼主| 发表于 2012-3-3 13:59:27 | 显示全部楼层
   没人回复
发表于 2012-3-4 15:28:43 | 显示全部楼层
 楼主| 发表于 2012-3-4 18:59:45 | 显示全部楼层
上面的贴已经看过了,,还是没办法判断。
发表于 2012-3-4 19:55:45 | 显示全部楼层
本帖最后由 nivisde 于 2012-3-4 19:57 编辑
Func GET_ONCOUT_CLIENT_NAME($SQLDATABASE_IPADDRESS,$SQLDATABASE_USERNAME,$SQLDATABASE_PASSWORD,$SQLDATABASE_VESION)
Local $SQL_CONNECTION = ObjCreate("ADODB.Connection")
$SQL_CONNECTION.Open("DRIVER={SQL Server};SERVER="&$SQLDATABASE_IPADDRESS&";UID="&$SQLDATABASE_USERNAME&";PWD="&$SQLDATABASE_PASSWORD)
$SQL_CONNECTION.Execute("use "&$SQLDATABASE_VESION);使用哪个数据库
Local $RS=ObjCreate("ADODB.Recordset");建立数据集
$RS.ActiveConnection =$SQL_CONNECTION
$RS.Open("Select sCom FROM tStat WHERE (sCardID<>'') ORDER BY sCom")
Local $ONCOUT_CLIENT_ARRAY[1][1] = [[0]]
Local $CONUT = 1 
Local $ID=0
While Not $RS.eof And Not $RS.bof 
        If @error = 1 Then ExitLoop
        If $ONCOUT_CLIENT_ARRAY[0][0] = 0 Then
                ReDim $ONCOUT_CLIENT_ARRAY[1][$RS.Fields.Count + 1]
                For $ID = 0 To $RS.Fields .Count - 1
                        $ONCOUT_CLIENT_ARRAY[0][$ID + 1] = $RS.Fields ($ID).Name
                Next
        EndIf
        ReDim $ONCOUT_CLIENT_ARRAY[$CONUT + 1][$RS.Fields.Count + 1]
        $ONCOUT_CLIENT_ARRAY[0][0] = $CONUT
        For $ID = 0 To $RS.Fields .Count - 1
                $ONCOUT_CLIENT_ARRAY[$CONUT][$ID + 1] = $RS.Fields($ID).Value
        Next
        $CONUT += 1
        $RS.movenext
WEnd
$RS.Close
$SQL_CONNECTION.Close
Return $ONCOUT_CLIENT_ARRAY
EndFunc
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-20 17:34 , Processed in 0.093919 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表