久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

確定查詢是否在 vb.net 中返回“無行"

Determining if a query returns #39;no rows#39; in vb.net(確定查詢是否在 vb.net 中返回“無行)
本文介紹了確定查詢是否在 vb.net 中返回“無行"的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我使用 MS SQL Server 作為數據庫,使用 VB.NET 作為后端.

I am using MS SQL Server as my database and VB.NET as my back-end.

我想確定我在 sql 命令文本中的查詢是否不返回任何行.我試圖有一個不返回任何行的查詢,然后將其值賦予一個變為 0 的文本框.(整數)

I want to determine if my query in sql command text returns no rows. I tried to have a query that returns no rows, and then give its value to a text box which became 0. (integer)

現在的問題是,當我在 If 條件中測試它時,它不起作用.代碼是這樣的:

The problem now, is that when I test it in an If condition, it doesn't work. The code is like this:

If (Query that returns no rows) = 0 Then
'condition
Else
'condition
End If

我嘗試了一個空字符串,但它仍然不起作用.請幫忙!如果可能,請給出問題的簡單解決方案.提前致謝!

I tried a blank string, but it still does not work. Please help! If possible, please give the simples solution to the problem. Thank you in advance!

推薦答案

@podiluska 是對的.您將必須執行該命令.正如我所看到的,您已經為 Command 對象的 CommandText 屬性分配了值,該屬性是您要執行的查詢.為了執行命令,您必須有一個打開的活動連接,然后調用命令對象上的 Execute 方法.以下偽代碼可能會有所幫助:

@podiluska is right. You will have to execute the command. As I can see you have assigned value for the CommandText property of Command object that’s the query you want to execute. In order to execute the command, you must have an open active connection followed by call to Execute method on command object. Following pseudo code might help:

Public Sub Temp(ByVal connectionString As String)
    Dim queryString As String = _
       " select * from example where id = 999;" 
    Using connection As New SqlConnection(connectionString)
        Dim command As New SqlCommand(queryString, connection)
        connection.Open()
        Dim reader As SqlDataReader = command.ExecuteReader()
        Try 
            If reader.Read() Then
               'If condition
            Else
               'condition with  no results
            End If
        Finally 
            reader.Close()
        End Try 
     End Using 
End Sub

這篇關于確定查詢是否在 vb.net 中返回“無行"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

What SQL Server Datatype Should I Use To Store A Byte[](我應該使用什么 SQL Server 數據類型來存儲字節 [])
Interpreting type codes in sys.objects in SQL Server(解釋 SQL Server 中 sys.objects 中的類型代碼)
Typeorm Does not return all data(Typeorm 不返回所有數據)
Typeorm .loadRelationCountAndMap returns zeros(Typeorm .loadRelationCountAndMap 返回零)
How to convert #39;2016-07-01 01:12:22 PM#39; to #39;2016-07-01 13:12:22#39; hour format?(如何將“2016-07-01 01:12:22 PM轉換為“2016-07-01 13:12:22小時格式?)
MS SQL: Should ISDATE() Return quot;1quot; when Cannot Cast as Date?(MS SQL:ISDATE() 是否應該返回“1?什么時候不能投射為日期?)
主站蜘蛛池模板: 成人免费在线播放视频 | 亚洲欧洲成人av每日更新 | 在线免费观看黄色av | 国内精品久久久久久影视8 最新黄色在线观看 | 三级av免费 | 久久97精品| av免费观看在线 | 九色 在线| 视频一二三区 | 蜜臀久久99精品久久久久久宅男 | 亚洲一区黄色 | 欧美一级三级在线观看 | 色性av| 成人av电影天堂 | 国产高清精品一区二区三区 | 成人精品视频99在线观看免费 | 精品视频一区二区 | 亚洲精品视频一区 | 日韩欧美精品在线 | 成人一区二区三区在线观看 | 亚洲精品电影网在线观看 | 国产福利在线 | 久久亚洲国产精品 | 色资源在线视频 | 国产精品免费在线 | 日韩欧美在线观看 | 欧美中文一区 | 欧美激情久久久 | 黄色大片网| 一级欧美| 欧美国产日韩在线观看 | 欧美午夜精品理论片a级按摩 | 欧美一级在线观看 | 久久久久综合 | 中文一区二区视频 | 午夜性色a√在线视频观看9 | 亚洲不卡在线观看 | 久久久av | 国产精品久久久久久久久久久久久久 | 无码一区二区三区视频 | 在线视频a|