www.webdeveloper.com
Results 1 to 3 of 3

Thread: Opening a database using ASP and button

  1. #1
    Join Date
    Feb 2003
    Location
    Ireland
    Posts
    17

    Question Opening a database using ASP and button

    Hi I am trying open a database (MS Access) via an ASP.

    It is a simple page with two options one link to enter the
    site and the other that will allow the database administrator
    access to the raw tables and records within. If possible I would like it to open the 'Main Menu' form in the database??
    I have included the database connection script below but don't know how to incorporate a button around it, nor the SQL that is needed to open the database.
    Security is not an issue regarding access to the database
    this is only for personal educational use only.

    <%

    Set Conn = Server.CreateObject("ADODB.Connection")Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("myDatabase.mdb") & ";pwd=myPassword"

    set rs = Server.CreateObject("adodb.RecordSet")
    rs.open "SELECT ???????

    %>

    Any guidance would be much appreciated!!

    Thanks!!

  2. #2
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    hi,
    not sure if this is exactly what your are looking for, but it should help you.
    If you have a form with a text box for inputting the table name and then post it back to itself you can then use this code:

    Code:
    <%
        p_table_name = Request.form("p_table_name")
    
        set tableSet = Server.CreateObject("ADODB.RecordSet")
        tableSet.Open p_table_name, databaseName, adOpenForwardOnly, adLockOptimistic, adCmdTable
    	p_numberOfColums = tableSet.fields.count
    %>
    <table>
    	<tr>
    <% 	for x = 0 to (p_numberofColums - 1 ) %>
    	<td> <%= tableSet.Fields(x).Name %>	</td>
    <%  next %>
    </tr> 
    <% while not tableSet.EOF %>
    <tr> <%  for each col in tableSet.Fields %>
           <td> <%= col.Value %> </td>
    <% next %>
    </tr><%  tableSet.MoveNext
        wend
        tableSet.Close
    %>
    </table>
    ----------------------------------

  3. #3
    Join Date
    Feb 2003
    Location
    Ireland
    Posts
    17

    Smile Ta!!!

    Thanks both for you input!!

    Ribeyed I couldn't really get my head around that code, not your fault of course I probably wasn't very clear in the first place, thanks anyway!!

    Thankyou too Dave, I think your comments have since proved true, no access to database forms just tables.

    Cheers,

    Portmoon

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles