Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases 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 September 21st, 2004, 08:40 AM
Registered User
 
Join Date: Sep 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default filling a combo box using an array

I am trying to fill a combo box using an array. I have tried filling the combo box using a dataset and I keep getting the same error.

This is my error:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 88: Do While dr.Read
Line 89: stAl.Add("CATEGORY_DESC")
Line 90: cbcategory_id.Items.Add("CATEGORY_DESC")
Line 91: Loop
Line 92:


Source File: c:\inetpub\wwwroot\WebApplication2\Default.aspx.vb Line: 90

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
   WebApplication2.WebForm4.LoadDataSet() in c:\inetpub\wwwroot\WebApplication2\Default.aspx.vb :90
   WebApplication2.WebForm4.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebApplication2\Default.aspx.vb :58
   System.Web.UI.Control.OnLoad(EventArgs e)
   System.Web.UI.Control.LoadRecursive()
   System.Web.UI.Page.ProcessRequestMain()


This is my Code:


    Private Sub LoadDataSet()
        Dim dr As OleDbDataReader
        Dim strQry As String
        Dim stAl As New ArrayList

        sqlComm = New OleDbCommand(strQry, DbConn)

        strQry = "SELECT CATEGORY_ID, CATEGORY_DESC FROM INCIDENT.CATEGORIES"
        DbConn.Open()

        sqlComm.CommandText = strQry
        dr = sqlComm.ExecuteReader()

        If dr.HasRows Then
            Do While dr.Read
                stAl.Add("CATEGORY_DESC")
                cbcategory_id.Items.Add("CATEGORY_DESC")
            Loop

        End If
        dr.Close()
        DbConn.Close()
    End Sub

Please help me as soon as possible.

Thanks in advance.

Trena





Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo box to display items from parent combo box Gini Visual Studio 2008 0 June 18th, 2008 12:30 AM
Combo box choice creating filtered combo box stevensj5 Access 11 September 13th, 2007 11:33 AM
Filling a combo box w/in datagridview kscase Visual Basic 2005 Basics 1 July 12th, 2007 07:26 AM
passing array from combo box thru ajax amorphic8 BOOK: Professional Ajax ISBN: 978-0-471-77778-6 0 July 10th, 2006 03:23 AM
filling a combo box from a data object allee_man Beginning VB 6 1 March 1st, 2005 08:08 AM





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