473,387 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem populating ddl from Oracle

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.getCo nnectionString)
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

Jun 12 '07 #1
1 1152
I resolved the problem, I was reusing code from a ddl within a datagrid and
that was making it more comples that needed:

buildYearDDLs(FindControl("ddlSample"))
to
buildYearDDLs(ddlSample)
&
DDLAddYear = CType(c, DropDownList)
to
DDLAddYear = c

Seemed to do the job just fine, I wanted to be able to pass the ddl since I
want to re-use the code for other ddls

Hope this helps someone in future
"Problematic coder" <gn******@gmail.comwrote in message
news:11**********************@x35g2000prf.googlegr oups.com...
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.getCo nnectionString)
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

Jun 12 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: simianphile | last post by:
OK, I had a problem that I've now fixed but I can't really understand what was causing it in the first place. I have an intranet site that uses basic authentication to allow users to view and...
5
by: SerGioGio | last post by:
Hello, I am going nuts. I am trying to connect to my local ORACLE instance using ODBC. It used to work few weeks ago, but it fails now. Connection with: - SQL*plus: connection works! -...
11
by: Ellen K | last post by:
Hi all, I set up our Oracle Financials as a linked server to one of my SQL Server boxes. On running a test query, I got the following error message: OLE DB provider 'MSDAORA' supplied...
3
by: Craig G | last post by:
i've emailed metabuilders themselves but was just wondering has anybody else ever had this problem? I am populating the combobox using a SQL2000 table. The combobox populates successfully with the...
5
by: | last post by:
Trying to learn about manipulating collections of objects, and populating these objects dynamically from datasources. Could someone post a code sample that shows the following: Instantiating a...
5
by: Michael Rudolph | last post by:
Hi newsgroup, I have an issue with the configuration of a DB2 federated database (WebSphere Information Integrator) in conjunction with the relational wrapper for Oracle on AIX. DB2 seems to not...
14
by: peteh | last post by:
Hi All; We have many production jobs that "load from cursor" to a UDB/AIX 8.2 (with dpf) data warehouse from source tables residing Oracle 9i. Since Oracle dates are (roughly) equivalent to DB2...
1
by: haselbw | last post by:
Hi all: I have searched the web for some info about this, but I can't find exactly what I'm looking for. I have a table in an Oracle database with user info that I need to get into AD. I think...
2
by: Problematic Coder | last post by:
I am populating a ddl from an Oracle table, this is working fine with one exception, when I scroll through the list of values in the ddl, right at the top there is a blank selection. There is no...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.