Filling Data into Select List
In this short ASP source code, we will pull some data from a database and fill it into a select list. We will create a custom and dynamic output.
Now first we need to connect a database. In this part of oced we prefer to connect MS SQL server. We have a sample database with some data inside.
You could easily modify this connection and use mySQL or MS Access.
<%
strConnection = "Provider=SQLOLEDB;Server=LOCAL_MS_SQL;User ID=TESTUSER;Password=;Database=glink30;"
%>
Let's play with this connection now. We need a database connection.
<%
set objConnection = server.creeateobject("adodb.connection")
objConnection.open strConnection
%>
Now we have connected to database. We need to get our records from our sample database.
<%
set objRecords = objConnection.execute("select catID, categoryName from glink_categories order by catID desc")
if objRecords.Eof then
response.write "Sorry, no results !"
else
%>
We have tested records. If there is no turning records, we will display a custom message to client taht there is no results in query.
<%
response.write " <SELECT name=catID size=""1""> "
response.write "<option>Choose Category</option>"
do while not objRec.eof
response.write "<option value="""& objRecords("catID") &""">"& objRecords("categoryName") & "</option>" & vbCrlf
objRecords.Movenext
loop
response.write "</select>"
%>
Call this page form your favorite browse (I prefer Mozilla Firefox), you will see that there is a select list contains category names.
Happy Coding !
- How to Refresh a web page or redirect to another page
- Custom Paging in ASP Fast And Easy
- Professional Contact Form
- Creating Access Database Connection String
- Using DateDiff function in SQL Statement
- Executing Transact SQL UPDATE statement using SQLCommand
- Custom Paging results in ASPNET using A Better Way
- Sending Emails in JSP
- MySQL AB Offers its Enterprise Database Subscriptions through the New Red Hat Exchange
- Display Top N records from MS Access
- How to display date time in real time
- JSP Hit Counter Free Open Code
- ASP Ikon Ad Manager UPDATED
- Exporting Data From mySQL to Excel
- Generating XML files from SQL Database
- Easy Download Manager Free Version
- ASP Chat Box
- Writing Form Data to Text Files
- Paging Records in JSP
- What is Ecommerce and the Importance of Ecommerce
- Beginning-Ajax-and-ASPNET-35
- How to upload images to mySQL within PHP
- Simple XML RSS Parser
- Counting records in PHP mySQL
- ActiveNews Manager Freeware News Exchange Software
- How to write and use a JavaBean My frst java bean
- Paging Results in PHP
- Free User Registration Form
- A-timesaver-control-GridView
- ASPNET Web Counter Free Open Source Code
- Easy Download Manager Free Version
- ASP Chat Box
- Writing Form Data to Text Files
- Paging Records in JSP
- Beginning-Ajax-and-ASPNET-35
- How to upload images to mySQL within PHP
- Simple XML RSS Parser
- ActiveNews Manager Freeware News Exchange Software
- Counting records in PHP mySQL
- How to write and use a JavaBean My frst java bean
- Paging Results in PHP
- Free User Registration Form
- A-timesaver-control-GridView
- ASPNET Web Counter Free Open Source Code
- Comparing Dates