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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking if DataAdapter has records

Status
Not open for further replies.

dvannoy

MIS
May 4, 2001
2,765
US
I'm using a adapter and dataset to populate a gridview. I need to be able to throw an error message if there is no record.

This doesn't seem to work. any help would be appreciated

Dim dgDS As New DataSet
Dim dgDA As New SqlDataAdapter(sCommand)

dgDA.Fill(dgDS, "MyTable")

If dgDS.Tables.Count = 0 Then
lerror.Visible = True
Exit Sub
connection.Close()

Else
dg1.DataSource = dgDS.Tables("MyTable")
dg1.DataBind()
connection.Close()

End If

 
never mind...was missing this

If dgDS.Tables(0).Rows.Count = 0 Then

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top