Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics 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 December 10th, 2007, 12:47 PM
Authorized User
 
Join Date: Oct 2006
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default dataset

Having a little problem generating a dataset. Instead of getting my data, system.data.datarowview pops up in the dropdownlist that I'm trying to generate. Can anyone enlighten me as to what I'm doing wrong? here's my code.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        If Not IsPostBack Then
            'BindState(ddlConame)
            SetInitialFocus(txtCoNumber)



            connAAP = New SqlConnection(Application("connAAP"))

            'Declare command that calls stored proc that retrieves the list of the companies
            Dim objCommand As New SqlCommand("spAAPSelectCompanies", connAAP)

            objCommand.CommandType = CommandType.StoredProcedure

            Dim dsCompany As New DataSet

            Dim adapter As New SqlDataAdapter(objCommand)


            'Load all the companies listboxes with the list of companies
            Try
                connAAP.Open() 'Open the connection
                adapter.Fill(dsCompany)
                connAAP.Close() 'Close the connection
                ddlConame.DataSource = dsCompany
                ddlConame.DataBind() 'Bind the list of the states to the state's listbox
                ddlConame.Items.Insert(0, "Select Company")
                ddlConame.Items.Item(0).Value = ""

            Catch excep As Exception
                Response.Write("<script language=javascript>alert(""Errors Encountered While Loading Companies into Company Listboxes!"");</script>")
            End Try
        End If
        txtconame.Visible = False
        ddlConame.Enabled = True
    End Sub

 
Old December 10th, 2007, 04:06 PM
Authorized User
 
Join Date: Oct 2006
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

got it working:)

 
Old December 11th, 2007, 01:49 PM
Registered User
 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In case one of us "newbies" (me!) have the same issue, What did you do to get it to work?

Thanks
Martha

 
Old December 11th, 2007, 01:59 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

It probably has to do with the fact that only a databind was preformed:

ddlConame.DataSource = dsCompany
ddlConame.DataBind() 'Bind the list of the states to the state's listbox

When you need to do something like this:
ddlConame.DataTextField = "<some field in the datasource>"
ddlConame.DataValueField = "<some field in the datasource>"
ddlConame.DataSource = <datasource>
ddlConame.DataBind()

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
 
Old December 17th, 2007, 01:20 PM
Authorized User
 
Join Date: Oct 2006
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 ddlConame.DataSource = dtrState
            ddlConame.DataTextField = "vchcompanyname"
            ddlCoName.DataBind()
            ddlCoName.Items.Insert(0, "Select Company")
            ddlCoName.Items.Item(0).Value = ""
            ddlCoName.Items.Insert(1, "Other..")

 
Old December 17th, 2007, 01:31 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Quote:
quote:Originally posted by dhoward
            ddlCoName.Items.Insert(0, "Select Company")
            ddlCoName.Items.Item(0).Value = ""
            ddlCoName.Items.Insert(1, "Other..")

Instead of adding these values each time, it would probably be better to add them to the DropDown Item Collection through the IDE and set the AppendDataBoundItems property to true.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill a DataSet from another DataSet kamranzafar C# 1 February 7th, 2007 11:14 AM
Fill(dataset) or dataset.load() salemkoten SQL Server 2005 1 November 2nd, 2006 11:04 PM
Converting a untyped dataset to a typed dataset daphnean Visual Studio 2005 0 July 13th, 2006 01:16 AM
Copy dataset to another dataset kapila VB.NET 2 November 13th, 2005 06:25 AM
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.