dropdown list and database connection

D

djharrison

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
 
K

Ken Schaefer

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


: 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top