I am actually following a tutorial in Beginning
VB.NET Web Programming in Visual Studio.NET ISBN: 7361, chapter 4, pages 130 to 133, that's not working for me.
I think this code is the source of my problem:
Code:
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
MyBase.HeaderMessage = "Assign Places"
LoadDataSet()
InitPlaces()
InitForm()
End Sub
Private ds As DataSet
Private Sub LoadDataSet()
Dim con As SqlConnection
Dim sql As String
Dim adExisting As SqlDataAdapter
Dim adPlaces As SqlDataAdapter
Dim adPlaceTypes As SqlDataAdapter
con = New SqlConnection( _
"Server=KEVINS\VSdotNET;user id=sa;Password=sa;Initial Catalog=Friends")
' Select the place's timelapse records, descriptions and type...
sql = "SELECT TimeLapse.*, Place.Name AS Place, "
sql &= "PlaceType.Name AS Type FROM TimeLapse, Place, PlaceType "
sql &= "WHERE TimeLapse.PlaceID = Place.PlaceID "
sql &= "AND Place.TypeID = PlaceType.TypeID "
sql &= "AND TimeLapse.UserID = '" & Context.User.Identity.Name & "'"
' Initialize the adapters...
adExisting = New SqlDataAdapter(sql, con)
adPlaces = New SqlDataAdapter( _
"SELECT * FROM Place ORDER BY TypeID", con)
adPlaceTypes = New SqlDataAdapter("SELECT * FROM PlaceType", con)
con.Open()
ds = New DataSet()
Try
' Proceed to fill the dataset...
adExisting.Fill(ds, "Existing")
adPlaces.Fill(ds, "Places")
adPlaceTypes.Fill(ds, "Types")
Catch
' Just pass the exception up...
Throw
Finally
con.Close()
End Try
End Sub
I have ran de-bug, but my dataset is empty. There is a combobox on the web form also that fill's no problem. Can anyone tell me why my dataset is not working.
Code:
If ds.Tables("Existing").Rows.Count > 0 Then
pnlExisting.Visible = True
Else
pnlExisting.Visible = False
End If
Rows.Count > 0 always evaluates to False...WHY???
Thanks in advance for any help with this...Kevin :)