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

dropdown list and database connection

I'm new to ASP and database programming but I am trying to connect to
a database using a concatenation of a strings and a menu item from a
form.
Ok here's what I have... an asp form that has a dropdown menu list
that finds *.mdb files in the current folder. It also has a 'Select'
button on it. I want the user click select and either in this page or
another (not sure which is best?) make a connection to the database
using the strPath string and the name of item choosen from the
dropdown menu. Here's my code. Any help is appreciated. Thanks.

<%
Dim strPath
strPath = "D:\My Web\LBSAR\myDBAdmin\"

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPath)

'Find Number of Files
varFileCount = 0
For Each objFile in objFolder.Files
varFileCount = varFileCount + 1
Next

' Put File Names into an Array
ReDim varFileNames(varFileCount)
n = 0

For Each objFile in objFolder.Files
n = n + 1

varFileName = objFSO.GetFileName(objFile.Name)
varFileType = objFSO.GetExtensionName(objFile.Name)
If (Left(varFileType, 3) = "mdb") Then

varFileNames(n) = objFile.Name
End If
Next

Set objFolder = Nothing
Set objFile = Nothing
Set objFSO = Nothing
%> <select name="database">
<option value=".">Please Select a Database</option>
<% For n = 1 To VarFileCount %>
<option value="<%=varFileNames(n)%>" >
<%=varFileNames(n)%></option>
<% Next %>
</select>
<input type="button" value="submit" class="button">

Thanks

Daryl
Jul 19 '05 #1
1 3341
You need to get the user to submit the information back to the server.

THen you can access Request.Form("database") to see what the user selected.

Cheers
Ken
"djharrison" <da************@netscape.net> wrote in message
news:75*************************@posting.google.co m...
: I'm new to ASP and database programming but I am trying to connect to
: a database using a concatenation of a strings and a menu item from a
: form.
: Ok here's what I have... an asp form that has a dropdown menu list
: that finds *.mdb files in the current folder. It also has a 'Select'
: button on it. I want the user click select and either in this page or
: another (not sure which is best?) make a connection to the database
: using the strPath string and the name of item choosen from the
: dropdown menu. Here's my code. Any help is appreciated. Thanks.
:
: <%
: Dim strPath
: strPath = "D:\My Web\LBSAR\myDBAdmin\"
:
: Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
: Set objFolder = objFSO.GetFolder(strPath)
:
: 'Find Number of Files
: varFileCount = 0
: For Each objFile in objFolder.Files
: varFileCount = varFileCount + 1
: Next
:
: ' Put File Names into an Array
: ReDim varFileNames(varFileCount)
: n = 0
:
: For Each objFile in objFolder.Files
: n = n + 1
:
: varFileName = objFSO.GetFileName(objFile.Name)
: varFileType = objFSO.GetExtensionName(objFile.Name)
: If (Left(varFileType, 3) = "mdb") Then
:
: varFileNames(n) = objFile.Name
: End If
: Next
:
: Set objFolder = Nothing
: Set objFile = Nothing
: Set objFSO = Nothing
: %> <select name="database">
: <option value=".">Please Select a Database</option>
: <% For n = 1 To VarFileCount %>
: <option value="<%=varFileNames(n)%>" >
: <%=varFileNames(n)%></option>
: <% Next %>
: </select>
: <input type="button" value="submit" class="button">
:
: Thanks
:
: Daryl
Jul 19 '05 #2

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

Similar topics

8
by: Kris Rockwell | last post by:
Hello, I have done the following to bind data to a DropDown box: 1. Drag SQLServer table onto web form to create data connection and data adapter. 2. Generate dataset by right-clicking on...
0
by: Pietje puk | last post by:
Hello, Since im quite new to ASP.NET i wanted to ask you folks what the best way is to create a WebForm for modifying 1 field from a record. The manipulation of this field can be done by using...
3
by: Jerry | last post by:
Hello everyone! I'm trying to populate a dropdown list from SQL Server but it's not being populated. I've tried all sorts of suggestions and examples that I found from Google but I just can not...
2
by: Peter | last post by:
ASP.NET 2003 In the DataGrid how do I select current cell value in the dropdown box when I click on the edit link, currently when I click on the edit link in the DataGrid the dropdown box...
2
by: Sam | last post by:
A) Destination Table with 4 Fields. 1) Last Name 2) First Name 3) State 4) Zip Code. B) Look up table State/Zip Code with 2 Fields
5
by: jung_h_park | last post by:
From: jung_h_park@yahoo.com Newsgroups: microsoft.public.dotnet.framework.aspnet Subject: Dropdown List not retaining its SelectedValue Date: Mon, 26 Jun 2006 21:02:57 -0700 Hello, My...
11
by: eureka | last post by:
Hi All, I'm training in Servlets, JSP and JavaScript, I have a web page in which there's a "StudentName" textbox and below it is a "Names" Dropdown list. Initially the Textbox is empty and...
3
by: Ninio | last post by:
I have a simple form with a dropdown menu that consists of 3 option and each option should retrieve a query from a database. i have been looking all over the place and can't seem to find how to do...
2
by: JJ297 | last post by:
I have a dropdown list populated via a database. I edited the dropdown list to have "select a topic" to always appear when the drop down loads. Now if a user selects a dropdown item it goes into...
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...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.