Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 22nd, 2004, 01:49 PM
Authorized User
 
Join Date: Sep 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataSet empty...help

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

 
Old June 22nd, 2004, 10:45 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

ur code seems fine. Did u tryed ur Existing Command in [u]Query Analyzer</u> doest it have row?!
Check it there, maybe its bc of ur SQL Command.

Always:),
Hovik Melkomian.
 
Old June 23rd, 2004, 10:18 AM
Authorized User
 
Join Date: Sep 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Hovik...I'm not quite sure how to use the Query Analyzer, is that part of Visual Studio?

Thanks...Kevin

 
Old June 23rd, 2004, 01:43 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Could be it's not returning the correct user: UserID = '" & Context.User.Identity.Name & "'"

Could be that you reload the dataset every time in the Page_Load (you need to do If Not Page.IsPostback, unless you want this):

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

It could be one of those.

Brian
 
Old June 23rd, 2004, 11:21 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

no dear its part of ur MS-SQL Server. u can see its shortcut at
[u]Start\Programs\Microsoft SQL Server\Query Analyzer</u>

check it & keep in touch.

Always:),
Hovik Melkomian.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Empty DataSet Populated By Stored Procedure WestAussie Visual Studio 2005 5 April 8th, 2008 02:42 PM
Converting a untyped dataset to a typed dataset daphnean Visual Studio 2005 0 July 13th, 2006 01:16 AM
Help checking for empty dataset Payback ASP.NET 1.0 and 1.1 Basics 5 March 28th, 2005 05:00 AM
Handling an empty dataset Payback Classic ASP Basics 2 January 21st, 2005 12:42 PM
Re: SQL Server dataset to ACCESS dataset dazzer ADO.NET 0 March 22nd, 2004 05:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.