Detecting an empty dataset
Posted on 2006-07-04
the followin is a section of code from an application
Private Sub Reg_NumTextBox_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Reg_NumTextBox.GotFocus
Stock_NumberTextBox.Text = UCase(Trim(Stock_NumberTextBox.Text))
WhereString = " WHERE [Stock Number] = '" & Stock_NumberTextBox.Text & "'"
SqlSelect = New SqlCommand(SqlStr & WhereString, SqlCon1)
Da1.SelectCommand = SqlSelect
' Would like something like:-
' if ds1.eof then
' msgbox("Stock Number" & Stock_NumberTextBox.Text & " does Not Exist")
' end if
This works fine, but I would like to be able to detect if the query returns no data - like .EOF in classic ADO.
Is there a simple way of doing this?