nuoyan 发表于 2012-3-3 00:20:07

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

#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 ) & "'")   查找失败后的返回值 ,怎么判断?

nuoyan 发表于 2012-3-3 13:59:27

{:face (245):}   没人回复

liui 发表于 2012-3-4 15:28:43

http://www.autoitx.com/thread-30634-1-2.html

nuoyan 发表于 2012-3-4 18:59:45

上面的贴已经看过了,,还是没办法判断。

nivisde 发表于 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 = []
Local $CONUT = 1
Local $ID=0
While Not $RS.eof And Not $RS.bof
        If @error = 1 Then ExitLoop
        If $ONCOUT_CLIENT_ARRAY = 0 Then
                ReDim $ONCOUT_CLIENT_ARRAY[$RS.Fields.Count + 1]
                For $ID = 0 To $RS.Fields .Count - 1
                        $ONCOUT_CLIENT_ARRAY[$ID + 1] = $RS.Fields ($ID).Name
                Next
        EndIf
        ReDim $ONCOUT_CLIENT_ARRAY[$CONUT + 1][$RS.Fields.Count + 1]
        $ONCOUT_CLIENT_ARRAY = $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
页: [1]
查看完整版本: 关于SQL如何判断查询失败的问题,请大家帮忙。