Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to choose from all tables in a database

Status
Not open for further replies.

cazeno

Technical User
Jun 30, 2000
23
0
0
DE
my problem is that i dont know how to get all tables in an listmenu displayed ?? after that i want to choose a table and the table or some specific rows are displayed.
??can somebody help out with that??
caz [sig][/sig]
 
I am not sure what you but below is how I understood you.

Are you accessing SQL Server or some other database? If you are using SQL Server than in order to get list of all the table in your list box you would say

SELECT [name]
FROM myDatabase..sysobjects
WHERE xtype= 'U' AND status >= 0
ORDER BY [name]

and if you are accessing MS Access you would say

SELECT [Name]
FROM MSysObjects
WHERE Type = 1 AND [Name] NOT LIKE "MSys*"
ORDER BY [Name]

Type=1 are Access tables, Type=4 are linked tables, Type=3 are Queries Type=-32764 are Reports.

OK, now this is a rough sample. It works through SQL Server
<%
sql = &quot;SELECT [name] FROM myDatabase..sysobjects &quot;
sql = sql + &quot;WHERE xtype= 'U' AND status >= 0 &quot;
sql = sql + &quot;ORDER BY [name]&quot;
set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
'The following is all in one line
conn.Open &quot;Provider=SQLOLEDB.1;Data Source=&quot;+ Request.ServerVariables(&quot;SERVER_NAME&quot;)+&quot;;User ID=uID;Password=pwd;Initial Catalog=<database name>;&quot;

set rs =conn.Execute(sql)

%>

Now you will create a listbox and under the <SELECT ...></SELECT> make sure that the recordset is not empty rs.EOF = False and populate the listbox. The code is too big to write it. [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top