473,569 Members | 2,590 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\myDBA dmin\"

Set objFSO = Server.CreateOb ject("Scripting .FileSystemObje ct")
Set objFolder = objFSO.GetFolde r(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(va rFileCount)
n = 0

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

varFileName = objFSO.GetFileN ame(objFile.Nam e)
varFileType = objFSO.GetExten sionName(objFil e.Name)
If (Left(varFileTy pe, 3) = "mdb") Then

varFileNames(n) = objFile.Name
End If
Next

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

Thanks

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

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

Cheers
Ken
"djharrison " <da************ @netscape.net> wrote in message
news:75******** *************** **@posting.goog le.com...
: 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\myDBA dmin\"
:
: Set objFSO = Server.CreateOb ject("Scripting .FileSystemObje ct")
: Set objFolder = objFSO.GetFolde r(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(va rFileCount)
: n = 0
:
: For Each objFile in objFolder.Files
: n = n + 1
:
: varFileName = objFSO.GetFileN ame(objFile.Nam e)
: varFileType = objFSO.GetExten sionName(objFil e.Name)
: If (Left(varFileTy pe, 3) = "mdb") Then
:
: varFileNames(n) = objFile.Name
: End If
: Next
:
: Set objFolder = Nothing
: Set objFile = Nothing
: Set objFSO = Nothing
: %> <select name="database" >
: <option value=".">Pleas e Select a Database</option>
: <% For n = 1 To VarFileCount %>
: <option value="<%=varFi leNames(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
278
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 the data adapter ad selecting generate dataset.
0
1293
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 dropdown list. Previously i've written a lot of these page's by not using the webcontrols, but now i've reached this magically moment that i want...
3
1969
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 get it to work. I am able to access the database from other pages and display a list of records, but I just can't get the data to go into the dd...
2
2841
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 appears in the cell, but allways the first item in the dropdown box is shown not the current cell value? How do I make the current value in the cell ...
2
9720
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
11876
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 dropdown list control does not retain its SelectedValue. Unless I read the SelectedValue right after the control has been loaded, populated, and assigned...
11
7368
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 the Dropdown doesnt have any items.. The requirement is that as soon as one goes on typing the letters in the StudentName-textbox the corresponding...
3
3471
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 that. If anyone out there can help me i will be very grateful. this is the form: <form id="form1" name="form1" method="post" action=""> ...
2
1431
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 the datagrid fine, but if a user selects "select a topic" I get an error message... Error converting nvarchar to int on adapter.Fill(ds) Here's...
0
7701
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...
0
7924
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. ...
0
8130
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
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...
0
3653
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...
1
2115
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
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
940
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...

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.