Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 4th, 2004, 12:37 PM
Authorized User
 
Join Date: Jan 2004
Location: Oklahoma City, , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default Get information into list box

Can anyone tell me how to put a single list box on a page and have "FName" and "LName" (from my table in database) appear in the listbox? I'm sure it's something simple, but I have no idea how to do it! Please, can someone help me?

Reply With Quote
  #2 (permalink)  
Old February 4th, 2004, 02:31 PM
Friend of Wrox
 
Join Date: Jan 2004
Location: , , USA.
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Concatenate your FName and LName fields in a single varibale

Dim Name
Name = rs("FName") & " " & rs("LName")

and use it in your dropdown menu

<option value="<%=Name%>"><%= Name %></option>
Reply With Quote
  #3 (permalink)  
Old February 5th, 2004, 12:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

You can also combine it in your select statement:

SELECT (FNAME + ' ' + LName) AS FullName FROM [tablename]

Or

SELECT (FNAME & ' ' & LName) AS FullName FROM [tablename]

The top one is for SQL Server and the bottom one is for Access (I believe, I don't work that much in Access). Then you can loop through the recordset using "FullName".
Reply With Quote
  #4 (permalink)  
Old February 6th, 2004, 10:55 PM
Authorized User
 
Join Date: Jan 2004
Location: Oklahoma City, , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is what I have. I don't get any errors now, but the option/list box is empty...What am I doing wrong?

<%
Dim adoCon
Dim rsAdmin
Dim strSQL
set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../database/mercy.mdb")
Set rsAdmin = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT (FNAME & ' ' & LName) AS FullName FROM [tblAdmin]"
rsAdmin.Open strSQL, adoCon
%>
<form name="form1" method="post" action="">
          <select name="select">
            <option value="<%=FullName%>"><%=FullName%></option>
          </select>
        </form>
<%
rsAdmin.Close
Set rsAdmin = Nothing
Set adoCon = Nothing
%>

Reply With Quote
  #5 (permalink)  
Old February 9th, 2004, 12:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: abu dbabi, , United Arab Emirates.
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<%
Dim adoCon
Dim rsAdmin
Dim strSQL
set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../database/mercy.mdb")
Set rsAdmin = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT (FNAME +' '+LName) AS FullName FROM tblAdmin"

rsAdmin.Open strSQL, adoCon
%>
<form name="form1" method="post" action="">
          <select name="select">
            <option value="<%=FullName%>"><%=FullName%></option>
          </select>
        </form>
<%
rsAdmin.Close
Set rsAdmin = Nothing
Set adoCon = Nothing
%>



Quote:
quote:Originally posted by stacy
 This is what I have. I don't get any errors now, but the option/list box is empty...What am I doing wrong?

<%
Dim adoCon
Dim rsAdmin
Dim strSQL
set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../database/mercy.mdb")
Set rsAdmin = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT (FNAME & ' ' & LName) AS FullName FROM [tblAdmin]"
rsAdmin.Open strSQL, adoCon
%>
<form name="form1" method="post" action="">
         <select name="select">
            <option value="<%=FullName%>"><%=FullName%></option>
         </select>
        </form>
<%
rsAdmin.Close
Set rsAdmin = Nothing
Set adoCon = Nothing
%>

Reply With Quote
  #6 (permalink)  
Old February 12th, 2004, 10:54 AM
Registered User
 
Join Date: Feb 2004
Location: Quilmes, Buenos Aires, Argentina.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'LL TRY TO GIVE SOME HELP.
Sorry for the inexperienced (it's my first post)

What I see is missing is the loop thru the records in te recordset.

You have to llop thru each record in order to achieve the FName, LName pair to put it in the option of the select.

So here's th e code for before and after your line <option value="<%=FullName%>"><%=FullName%></option>

Before
<% Do While Not rsAdmin.Eof %>

I'll also change a little the select option clause just in case
<option value="<%=rsAdmin("FullName)%>"><%=rsAdmin("FullNa me")%></option>

And After
<% rsAdmin.Movenext
   Loop %>

That's all (I havn't test it, may be you find something to check)

Best regards
Tell me if it works

Quote:
quote:Originally posted by mateenmohd
 <%
Dim adoCon
Dim rsAdmin
Dim strSQL
set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../database/mercy.mdb")
Set rsAdmin = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT (FNAME +' '+LName) AS FullName FROM tblAdmin"

rsAdmin.Open strSQL, adoCon
%>
<form name="form1" method="post" action="">
         <select name="select">
            <option value="<%=FullName%>"><%=FullName%></option>
         </select>
        </form>
<%
rsAdmin.Close
Set rsAdmin = Nothing
Set adoCon = Nothing
%>



Quote:
quote:Originally posted by stacy
 This is what I have. I don't get any errors now, but the option/list box is empty...What am I doing wrong?

<%
Dim adoCon
Dim rsAdmin
Dim strSQL
set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../database/mercy.mdb")
Set rsAdmin = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT (FNAME & ' ' & LName) AS FullName FROM [tblAdmin]"
rsAdmin.Open strSQL, adoCon
%>
<form name="form1" method="post" action="">
         <select name="select">
            <option value="<%=FullName%>"><%=FullName%></option>
         </select>
        </form>
<%
rsAdmin.Close
Set rsAdmin = Nothing
Set adoCon = Nothing
%>

Reply With Quote
  #7 (permalink)  
Old February 20th, 2004, 01:08 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Minneapolis, MN, USA.
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

Make sure you have that loop inside of your select tags as well or you will get multiple list boxes.

<select name="select">
<%Do While Not rsAdmin.Eof%>
<option value="<%=rsAdmin("FullName)%>"><%=rsAdmin("FullNa me")%></option>
<%
rsAdmin.movenext
loop
%>
</select>

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Grab Values From List Box into Text Box phungleon VB How-To 2 June 19th, 2008 10:33 PM
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
select box/List box alphabetic sort sasidhar79 Javascript How-To 3 November 10th, 2004 03:04 AM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM
Search using drop down list box and a text box tcasp Classic ASP Basics 1 July 31st, 2003 02:58 PM



All times are GMT -4. The time now is 04:01 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.