473,790 Members | 2,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Populating a Listbox

Hi there,

I am currently running into a somewhat weired problem and hope that this NG
is able to help ;-)

I have a table in a MSSQL Server in which there is one Column that stores a
date. The Format is 04.03.2004

Now I want to populate a Listbox but only with the year from that Column. So
if I have lets say 10 entries with *.*.2004 and 5 with *.*.2003 I just want
to show 2003 and 2004 once in the Listbox.
Basically intended for a Searchform to search for entries from a specific
year.
I can get the Listbox to display the years allright but if I have 1000
entries in the Column I gett as much in the Listbox.
This is the Code I have so far

<select name="select">
<%
While (NOT rsMyDate.EOF)
%>
<option value="<% Response.Write (Month
(rsMyDate.Field s.Item("Date"). Value)) %>"><% Response.Write (Month
(rsMyDate.Field s.Item("Date"). Value)) %></option>
<%
rsMyDate.MoveNe xt()
Wend
If (rsMyDate.Curso rType > 0) Then
rsMyDate.MoveFi rst
Else
rsMyDate.Requer y
End If
%>
</select>
Any ideas are greatly appreciated.

Cheers

Btw..sorry 4 crossposting ;-)
Jul 19 '05 #1
3 1972
Why is the date stored as a string and not a datetime value? If it was a
datetime value then you could use the intrinsic SQL functions to return the
relevant date part.

Chris.

"Broder" <br**********@g mx.net> wrote in message
news:c2******** *****@news.hans enet.net...
Hi there,

I am currently running into a somewhat weired problem and hope that this NG
is able to help ;-)

I have a table in a MSSQL Server in which there is one Column that stores a
date. The Format is 04.03.2004

Now I want to populate a Listbox but only with the year from that Column. So
if I have lets say 10 entries with *.*.2004 and 5 with *.*.2003 I just want
to show 2003 and 2004 once in the Listbox.
Basically intended for a Searchform to search for entries from a specific
year.
I can get the Listbox to display the years allright but if I have 1000
entries in the Column I gett as much in the Listbox.
This is the Code I have so far

<select name="select">
<%
While (NOT rsMyDate.EOF)
%>
<option value="<% Response.Write (Month
(rsMyDate.Field s.Item("Date"). Value)) %>"><% Response.Write (Month
(rsMyDate.Field s.Item("Date"). Value)) %></option>
<%
rsMyDate.MoveNe xt()
Wend
If (rsMyDate.Curso rType > 0) Then
rsMyDate.MoveFi rst
Else
rsMyDate.Requer y
End If
%>
</select>
Any ideas are greatly appreciated.

Cheers

Btw..sorry 4 crossposting ;-)

Jul 19 '05 #2
Hi there,

excuse my ignorance but I have to confess I never heard of them ;-).
Actually in the DB it is stored in datetime

Broder

"Chris Barber" <ch***@blue-canoe.co.uk.NOS PAM> schrieb im Newsbeitrag
news:OY******** ******@TK2MSFTN GP09.phx.gbl...
Why is the date stored as a string and not a datetime value? If it was a
datetime value then you could use the intrinsic SQL functions to return the relevant date part.

Chris.

"Broder" <br**********@g mx.net> wrote in message
news:c2******** *****@news.hans enet.net...
Hi there,

I am currently running into a somewhat weired problem and hope that this NG is able to help ;-)

I have a table in a MSSQL Server in which there is one Column that stores a date. The Format is 04.03.2004

Now I want to populate a Listbox but only with the year from that Column. So if I have lets say 10 entries with *.*.2004 and 5 with *.*.2003 I just want to show 2003 and 2004 once in the Listbox.
Basically intended for a Searchform to search for entries from a specific
year.
I can get the Listbox to display the years allright but if I have 1000
entries in the Column I gett as much in the Listbox.
This is the Code I have so far

<select name="select">
<%
While (NOT rsMyDate.EOF)
%>
<option value="<% Response.Write (Month
(rsMyDate.Field s.Item("Date"). Value)) %>"><% Response.Write (Month
(rsMyDate.Field s.Item("Date"). Value)) %></option>
<%
rsMyDate.MoveNe xt()
Wend
If (rsMyDate.Curso rType > 0) Then
rsMyDate.MoveFi rst
Else
rsMyDate.Requer y
End If
%>
</select>
Any ideas are greatly appreciated.

Cheers

Btw..sorry 4 crossposting ;-)

Jul 19 '05 #3
In which case use the DatePart function to output the specific part of the
datetime value that you want. It's also better when updating the database to
pass in an ISO datetime string in the SQL so that the database cannot
misinterpret your dates as either US or UK etc.

http://www.databasejournal.com/featu...le.php/2197931
http://www.databasejournal.com/featu...0894_2209321_2
http://www.techonthenet.com/access/f...e/datepart.htm
http://www.informit.com/articles/article.asp?p=31453

Chris.

"Broder" <br**********@g mx.net> wrote in message
news:c2******** *****@news.hans enet.net...
Hi there,

excuse my ignorance but I have to confess I never heard of them ;-).
Actually in the DB it is stored in datetime

Broder

"Chris Barber" <ch***@blue-canoe.co.uk.NOS PAM> schrieb im Newsbeitrag
news:OY******** ******@TK2MSFTN GP09.phx.gbl...
Why is the date stored as a string and not a datetime value? If it was a
datetime value then you could use the intrinsic SQL functions to return the relevant date part.

Chris.

"Broder" <br**********@g mx.net> wrote in message
news:c2******** *****@news.hans enet.net...
Hi there,

I am currently running into a somewhat weired problem and hope that this NG is able to help ;-)

I have a table in a MSSQL Server in which there is one Column that stores a date. The Format is 04.03.2004

Now I want to populate a Listbox but only with the year from that Column. So if I have lets say 10 entries with *.*.2004 and 5 with *.*.2003 I just want to show 2003 and 2004 once in the Listbox.
Basically intended for a Searchform to search for entries from a specific
year.
I can get the Listbox to display the years allright but if I have 1000
entries in the Column I gett as much in the Listbox.
This is the Code I have so far

<select name="select">
<%
While (NOT rsMyDate.EOF)
%>
<option value="<% Response.Write (Month
(rsMyDate.Field s.Item("Date"). Value)) %>"><% Response.Write (Month
(rsMyDate.Field s.Item("Date"). Value)) %></option>
<%
rsMyDate.MoveNe xt()
Wend
If (rsMyDate.Curso rType > 0) Then
rsMyDate.MoveFi rst
Else
rsMyDate.Requer y
End If
%>
</select>
Any ideas are greatly appreciated.

Cheers

Btw..sorry 4 crossposting ;-)


Jul 19 '05 #4

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

Similar topics

1
1988
by: cloverme | last post by:
Hi, I need help populating a listbox from a database on a webform. I created a an access database with a table, fields and data. Then I created a WebForm in vb.net and added a DropDownList control to the page. Then I created a data connection to my table... I right clicked and told it to generate a dataset (which it created dataset1).
0
1354
by: Bill Brinkworth | last post by:
I want the user to type in part of a word, and I want to return all words from an Access word table that contains specified letters. If they were to type "fe??", it should return all words in the dictionary that are 4 letters and begin with "fe" into a listbox. I am having difficulting searching for all words and taking all those words and populating a listbox. Can you help? Here's what I have: CLASS - Public Property word() As String...
6
7563
by: Deano | last post by:
I needed to have a listbox populated by locations which are stored in tblLocations. However I wanted an "All locations" entry to be at the top of the listbox. This is not in the tblLocations. The resulting list will be used to provide a query parameter and the user can choose all locations (the default) or a single, specific location. In the open event of the form containing the listbox I wrote the following code to achieve this. Could...
2
2915
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However, currently the code is such that with each selection there is a postback. We want to avoid it using filter and javascript. I am not using ADO.NET but adodbc and no datagrids or datasets (please don't tell me that i should as my boss clearly doesn't want...
6
2883
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset a denormalized mirror of the database, but I'm not having much luck getting the selection logic down (I haven't found a 'hook' where I can access the listbox object as an object to set the listitem's selected property before it gets rendered).. ...
6
1580
by: P K | last post by:
I have a listbox which I am populating on the client (it contains a list of dates selected from calender). The listbox is a server control. When I get to the server after postback by selecting an item in the list, the list box cannot be accessed. How do I repopulate the listbox on the server after postback and be able to access the elements?
15
26703
by: NasirMunir | last post by:
I am trying to populate a listbox from another listbox on a access form. My first listbox has names of tables on a linked odbc databse. I am trying to display the tuples of the table in the second listbox based on the selection of table name in the first listbox I am new to VBA, and am trying to do that in the following manner: Private Sub List0_BeforeUpdate(Cancel As Integer) Dim strTable As String strTable = List0.Value ...
2
3831
by: NvrBst | last post by:
I populate a ListBox with a LogFile that has about (~1000 lines). The ListBox's datasource is a BindingList<string>. Whenever I add the elements, with the datasource set, it takes about 2 mins. I've tried wrapping "Listbox.SuspendLayout()" and "Listbox.ResumeLayout()" around the for loop (that does the adding) but it still takes about 2 mins. Only thing I can seem to do is set the DataSource to null, add to the BindingList and then...
1
12885
by: dkohel | last post by:
I have 2 list boxes on my form. I am trying to populate listbox B with the selection from listbox A. I have set multi-select in both boxes to Extended... The user will select the items from listbox A and click an Add button that will then copy the items to listbox B. Then for each item in B, I need to add them to a database. If there are 3 items in listbox B, I need to add 3 line items to table B... Any ideas?
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10413
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4094
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.