Solved

Search Tables on Access Database, With ASP

Posted on 1998-08-10
6
196 Views
Last Modified: 2013-12-25
I like Know the tables in a Access Database, but I like open and view with Access

Open Database with ADO and any trick to view existing tables.
0
Comment
Question by:juliomb
6 Comments
 

Author Comment

by:juliomb
ID: 1858924
Edited text of question
0
 
LVL 28

Expert Comment

by:sybe
ID: 1858925
Ok, here are the steps to take in ASP

First make an ODBC connection to the database (control panel, ODBC32). Remember the name you gave it, for the sample code below I'll call it "MyODBC"

The rest is ASP code, here are the steps.

<%
' make a connection to the ODBC source
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=MyODBC"
' Now you have a connection named "Conn"

' make a recordset

Set RS = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM MyTable"
'you can make any SQL statement that works in Acces
'including WHERE, JOIN ORDER BY etc
RS.Open strSQL, Conn, 1, 1
'Now you have the recordset

'Show the records in the page

Do While Not RS.EOF

  Response.write RS("FieldName1") & ", " & RS("FieldName2") & "<br>"

RS.MoveNext
Loop
RS.Close

' This loop will display the contents of all the records
' You might want to change the HTML design of it, but that is not hard to do.
%>









%>




0
 

Author Comment

by:juliomb
ID: 1858926
Hello Sybe.
Well, The code for open a Table it's know,

I not Know, its the name of table to operate with it.

I like a recordset with names of TABLES, not open a table.

Open Database, and know names of tables into databaseç

Thanks.


0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Expert Comment

by:wanted
ID: 1858927
Your table's names in MSysObjects.(if you cann't see the table object, please check the  state in menu bar 'tool'->'option'->'system object' must be select)
If Type field is 1 and Flags field is 0, then Name field contain those table name.

select Name from MSysObjects where Flags=0 and Type=1
0
 
LVL 4

Accepted Solution

by:
mcix earned 200 total points
ID: 1858928
Try this:

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=YourODBCDSN"
Set RS = Server.CreateObject("ADODB.Recordset")
strSQL = "Select * From MSysObjects Where Type =1 AND Flags= 0"
RS.Open strSQL, Conn, , , adCmdText
RS.MoveFirst
Do Until RS.EOF
    Response.write "TABLE NAME IS :" & RS("Name")& "<br>"
    RS.MoveNext
Loop

RS.Close
Conn.Close

%>

If you get an Access security error, check the permissions for the User you are logging in as and make sure they have BOTH read design and read data flagged on MSysObjects.

By default, Access does not even set the Admin user with the
ANY permissions for the MSysObjects table.

0
 

Expert Comment

by:wanted
ID: 1858929
Hi, juliomb:
you say:
>:Well, The code for open a Table it's know,
>:I not Know, its the name of table to operate with it.
>:I like a recordset with names of TABLES, not open a table.
so I told you "select Name from MSysObjects where Flags=0 and Type=1"
What's wrong? Why reject my ans.?
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question