473,385 Members | 1,944 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,385 software developers and data experts.

multiple dropdown lists = multiple data readers???

Hi,

I've have a form for the user to fill in which comprises of 5 date ranges,
each made up of a "FROM" & "TO" date, which is built from a "[Month]"
dropdownlist & a "[Day]" dropdownlist, as follows:

Period 1 = FROM [Month][day] TO [Month][Day]
Period 2 = FROM [Month][day] TO [Month][Day]
Period 3 = FROM [Month][day] TO [Month][Day]
Period 4 = FROM [Month][day] TO [Month][Day]
Period 5 = FROM [Month][day] TO [Month][Day]

Ordinarily I use the following code to bind up a dropdownlist:

If IsPostBack = False Then
Dim objCn As New Odbc.OdbcConnection("DSN=IRS")
Dim objCmd As New Odbc.OdbcCommand("SELECT DISTINCT
tblHoliday.Country FROM tblHoliday", objCn)
Dim objDr As Odbc.OdbcDataReader

objCn.Open()
objDr = objCmd.ExecuteReader

Me.cboCountries.DataSource = objDr

Me.cboCountries.DataTextField = "Country"
Me.cboCountries.DataValueField = "Country"
Me.cboCountries.DataBind()
objDr.Close()
objCn.Close()

End If

I've got the months and days each in a separate lookup table, but I'm faced
with the prospect of having to run the above routine 10 times each for both
the days and months in order to populate the combos.

Is there an easier way to do this?

Thanks in advance

Andy

Nov 18 '05 #1
1 1294
Doh!

Sussed it.

"Andrew Kidd" <an****@nospamtoday.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hi,

I've have a form for the user to fill in which comprises of 5 date ranges,
each made up of a "FROM" & "TO" date, which is built from a "[Month]"
dropdownlist & a "[Day]" dropdownlist, as follows:

Period 1 = FROM [Month][day] TO [Month][Day]
Period 2 = FROM [Month][day] TO [Month][Day]
Period 3 = FROM [Month][day] TO [Month][Day]
Period 4 = FROM [Month][day] TO [Month][Day]
Period 5 = FROM [Month][day] TO [Month][Day]

Ordinarily I use the following code to bind up a dropdownlist:

If IsPostBack = False Then
Dim objCn As New Odbc.OdbcConnection("DSN=IRS")
Dim objCmd As New Odbc.OdbcCommand("SELECT DISTINCT
tblHoliday.Country FROM tblHoliday", objCn)
Dim objDr As Odbc.OdbcDataReader

objCn.Open()
objDr = objCmd.ExecuteReader

Me.cboCountries.DataSource = objDr

Me.cboCountries.DataTextField = "Country"
Me.cboCountries.DataValueField = "Country"
Me.cboCountries.DataBind()
objDr.Close()
objCn.Close()

End If

I've got the months and days each in a separate lookup table, but I'm faced with the prospect of having to run the above routine 10 times each for both the days and months in order to populate the combos.

Is there an easier way to do this?

Thanks in advance

Andy

Nov 18 '05 #2

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

Similar topics

0
by: Toonman | last post by:
I have a webpage with a <form> consisting of a large table grid of dropdown lists used to make changes in a database. Some of these dropdown lists have the same value. I'm trying to make it so...
0
by: Henke | last post by:
Hi, I have done some research about my problem I have when using the "back button" in IE to go back to a page with two dropdown lists. The both dropdown lists are populated with data. The...
3
by: Andrew Kidd | last post by:
Hi, I've have a form for the user to fill in which comprises of 5 date ranges, each made up of a "FROM" & "TO" date, which is built from a "" dropdownlist & a "" dropdownlist, as follows: ...
3
by: simon | last post by:
hello, i have a form where there are multiple dropdown lists that will all be populated from the same initial data query. i have a vb class defined to make the stored proc call and that returns a...
0
by: jmawebco | last post by:
I would like to know of anyone could tell me if the following is possible; I want to create a user control that will retrieve data from a database and create 4 seperate dropdown lists. The data...
2
by: Lair | last post by:
I am creating a page that has three to four databound dropdown lists. Each one is has different data sometimes from the same table but with a different where clause. What is the best way to...
8
by: Ed Dror | last post by:
Hi there ASP.NET 2.0 VB & SQL Express Lest take Northwind Categories Products as example I create a table that hold these two together and I create a stored procedure like select ProductID,...
2
by: PAzevedo | last post by:
I have this Hashtable of Hashtables, and I'm accessing this object from multiple threads, now the Hashtable object is thread safe for reading, but not for writing, so I lock the object every time I...
4
by: Paul | last post by:
Hi all, I have a page that has a form on it which has a dropdown list on it. It connect to an sql database and populate the list. What I would like to do is make the list editable so that if the...
3
by: John | last post by:
I have two dropdown lists that I have bound to a datatable and set the DataTextField and DataValueField for. Both lists show the values I expect from the database. However, when I need to access...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.