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
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