Click to See Complete Forum and Search --> : Opening a database using ASP and button


Portmoon
02-24-2003, 10:06 AM
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!!

Ribeyed
02-24-2003, 01:41 PM
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:


<%
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>

Portmoon
02-25-2003, 05:16 PM
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