P
Problematic coder
Here is the main code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
buildYearDDLs(FindControl("ddlSample"))
End sub
Private Sub buildYearDDLs(ByVal c As Control)
Dim objdr As Data.OracleClient.OracleDataReader = Nothing
Dim objcnn As Data.OracleClient.OracleConnection = Nothing
Dim objcom As Data.OracleClient.OracleCommand = Nothing
Dim strErrorMsg As String = ""
Dim DDLAddYear As DropDownList = Nothing
Dim liBlank As ListItem = Nothing
Try
objcnn = New
Data.OracleClient.OracleConnection(utilities.getConnectionString)
objcnn.Open()
objcom = New
Data.OracleClient.OracleCommand(utilities.BuildSQL("populateYear",
"None"), objcnn)
objdr = objcom.ExecuteReader()
Try
DDLAddYear = CType(c, DropDownList)
With DDLAddYear
.DataSource = objdr ' This is where I get the
error described below
.DataTextField = "DDL_YEAR"
.DataValueField = "DDL_YEAR"
.DataBind()
End With
liBlank = New ListItem("", "")
DDLAddYear.Items.Insert(0, liBlank)
Catch ex As Exception
'Deal with error
Finally
objdr.Close()
End Try
Catch ex As Exception
'Deal with error
Finally
End Try
End Sub
The error is:
System.NullReferenceException: Object reference not set to an instance
of an object. at interest_form.buildYearDDLs(Control c) in C:
\Documents and Settings\uid\My Documents\Visual Studio 2005\WebSites
\WebSite5\page.aspx.vb:line ....
I have no idea why I am getting this, I would appreciate any
assistance
Thanks
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
buildYearDDLs(FindControl("ddlSample"))
End sub
Private Sub buildYearDDLs(ByVal c As Control)
Dim objdr As Data.OracleClient.OracleDataReader = Nothing
Dim objcnn As Data.OracleClient.OracleConnection = Nothing
Dim objcom As Data.OracleClient.OracleCommand = Nothing
Dim strErrorMsg As String = ""
Dim DDLAddYear As DropDownList = Nothing
Dim liBlank As ListItem = Nothing
Try
objcnn = New
Data.OracleClient.OracleConnection(utilities.getConnectionString)
objcnn.Open()
objcom = New
Data.OracleClient.OracleCommand(utilities.BuildSQL("populateYear",
"None"), objcnn)
objdr = objcom.ExecuteReader()
Try
DDLAddYear = CType(c, DropDownList)
With DDLAddYear
.DataSource = objdr ' This is where I get the
error described below
.DataTextField = "DDL_YEAR"
.DataValueField = "DDL_YEAR"
.DataBind()
End With
liBlank = New ListItem("", "")
DDLAddYear.Items.Insert(0, liBlank)
Catch ex As Exception
'Deal with error
Finally
objdr.Close()
End Try
Catch ex As Exception
'Deal with error
Finally
End Try
End Sub
The error is:
System.NullReferenceException: Object reference not set to an instance
of an object. at interest_form.buildYearDDLs(Control c) in C:
\Documents and Settings\uid\My Documents\Visual Studio 2005\WebSites
\WebSite5\page.aspx.vb:line ....
I have no idea why I am getting this, I would appreciate any
assistance
Thanks