Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to evaluate if dataset is empty 1

Status
Not open for further replies.

Darci

IS-IT--Management
Jul 23, 2002
37
0
0
US
Hi...

I am building a form and need to evaluate whether or not the data set contains records....I can't seem to find the method.....here is what I have so far

Connect = New SqlConnection("Server=SERVER;Integrated Security=SSPI;Database=Manifest;")

strRouteSQL = "SELECT BankID, RouteID from BankRoutetbl Where BankID = " & Me.cmbBankList.SelectedValue & ""

dapRoute = New SqlDataAdapter(strRouteSQL, Connect)
dapRoute.Fill(dsRouteList, "RouteTbl")

cmbBankList.DataSource = dsRouteList.Tables("RouteTbl")

If dsRouteList.(Routetbl) DOES NOT CONTAIN RECORDS
(this is where I am stuck!)

Then Message to user

Else

cmbBankList.DisplayMember = dsRouteList.Tables("RouteTbl").Columns("RouteID").ToString

cmbBankList.ValueMember = dsRouteList.Tables("RouteTbl").Columns("RouteID").ToString

Connect.Close()
 
if dsRouteList.Tables("RouteTbl").Rows.Count>0 then
doStuff
end if
 
I use this function I picked up somewhere a long time ago. Define it as a public function somewhere you can get to it from anywhere (such as a code module)

Public Function IsEmptyRS(ByRef rsInput As ADODB.Recordset) As Boolean
IsEmptyRS = False
If rsInput.EOF And rsInput.BOF Then IsEmptyRS = True
End Function

Just call the function and pass the dataset (recordset) name, and you get back a true/false answer from the function on whether there are any returned records or not.

Hope this helps

CraigHartz
 
Thanks you guys!!! I was so close....guess that is how you learn....thanks again

Darci
 
This will also give you a record count.

intRowCnt = objDataAdpt.Fill(objDataSet)
 
CraigHartz, I like your function. I am sure that it is working in ADODB, but for dataset, do I need do some change? How to pass?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top