Solved

Search Tables on Access Database, With ASP

Posted on 1998-08-10
6
193 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now