|
-
May 6th, 2002, 12:47 PM
#1
Thread Starter
Frenzied Member
Tables in DB
How do I find out how many tables there are in a database using SQL or ADO????
Thanx,
Squirrelly1
-
May 6th, 2002, 01:14 PM
#2
This will list them, will that help?
VB Code:
Private Sub GetDbTables()
Dim Cnxn As ADODB.Connection
Dim rstSchema As ADODB.Recordset
Dim strCnxn As String
Set Cnxn = New ADODB.Connection
strCnxn = "Provider=sqloledb;Data Source=MyServer;Initial Catalog=Pubs;User Id=sa;Password=; "
Cnxn.Open strCnxn
Set rstSchema = Cnxn.OpenSchema(adSchemaTables)
Do Until rstSchema.EOF
List1.AddItem "Table name: " & rstSchema!TABLE_NAME & vbCr & "Table type: " & rstSchema!TABLE_TYPE & vbCr
rstSchema.MoveNext
Loop
' clean up
rstSchema.Close
Cnxn.Close
Set rstSchema = Nothing
Set Cnxn = Nothing
End Sub
-
May 6th, 2002, 01:30 PM
#3
Thread Starter
Frenzied Member
criteria
Is there any way to show just the tables where the table type is "TABLE". All of the other tables are irrelavent...
thanx again,
Squirrelly1
-
May 6th, 2002, 01:38 PM
#4
Thread Starter
Frenzied Member
actually...
actually, I need to be able to loop through them all and pull data from them based on a criteria string in sql...
This is some cool code, but now that I think of it, it won't really help me.
Do you know how to do what I need?
squirrelly1
-
May 6th, 2002, 01:52 PM
#5
Well, I never had the need to do this before, but I should work.
Modify the code I gave you and use rstSchema!TABLE_TYPE = 'Whatever'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|