dropdown list and database connection

Ask a Question related to ASP, Design and Development.

  1. #1

    Default 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
    djharrison Guest

  2. Similar Questions and Discussions

    1. Dropdown list
      I would like to display 15 items (lines) in the dropdown list, but by default the list displays only 11 lines. How can I have all the 15 items...
    2. Refresh dropdown list
      On a cfform I have a cfselect dropdown . The situtation is that when an option isn't listed I have a "Add button" next to the drop down that...
    3. Tool Tip for DropDown list
      Hi, I have a dropwnlist of fixed width. The item names in the dropdown list are quite big. The Tooltip property for a dropdownlist control...
    4. Write contents of Dropdown list to a database
      i am dynmically creating a dropdown list and i am wondering how to write the contents of the dropdown list to a database. Purpose: i am creating...
    5. Write entire contents of dropdown list to a database
      i am dynmically creating a dropdown list and i am wondering how to write the contents of the dropdown list to a database. Purpose: i am creating...
  3. #2

    Default Re: dropdown list and database connection

    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" <daryljharrison@netscape.net> wrote in message
    news:75e82834.0309242244.de11521@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


    Ken Schaefer Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139