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