473,385 Members | 1,400 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 1293
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.