How can I know how many tabels are in the database and what are they names?
(in running time)
thank you very much
chiki
Printable View
How can I know how many tabels are in the database and what are they names?
(in running time)
thank you very much
chiki
Chiki,
What backend database are you using? It is a very easy query if you are
using MS Access.
Arthur Wood
"chiki" <rpo@hotmail.co.il> wrote:
>
>How can I know how many tabels are in the database and what are they names?
>(in running time)
>
>
>thank you very much
>
>chiki
Chiki:
If you are using DAO then:
Private Sub Form_Load()
Dim sTemp As String
Dim db As Database
Dim tb As TableDef
Set db = OpenDatabase("c:\mmi-pm\Compile History.mdb")
For Each tb In db.TableDefs
If (tb.Attributes And dbSystemObject) = 0 Then
sTemp = "Normal Table: "
Else
sTemp = "System Table: "
End If
Debug.Print sTemp & tb.Name
Next
Unload Me
End Sub
Output sample:
System Table: MSysACEs
System Table: MSysModules
System Table: MSysModules2
System Table: MSysObjects
System Table: MSysQueries
System Table: MSysRelationships
Normal Table: tblAsgnApplicationToFile
Normal Table: tblCompiledApplication
Normal Table: tblCompiledFile
Normal Table: tblControl
Cheers,
Larry Rebich
More tips link to:
http://www.buygold.net/tips.html
Please:
No personal e-mail questions :-)
"chiki" <rpo@hotmail.co.il> wrote in message
news:3a322657$1@news.devx.com...
>
> How can I know how many tabels are in the database and what are they
names?
> (in running time)
>
>
> thank you very much
>
> chiki
Have you tried the OpenSchema method on the ADO connection?
Here is an example from the MSDN help file.
'BeginOpenSchemaVB
Public Sub OpenSchemaX()
Dim cnn1 As ADODB.Connection
Dim rstSchema As ADODB.Recordset
Dim strCnn As String
Set cnn1 = New ADODB.Connection
strCnn = "Provider=sqloledb;" & _
"Data Source=MyServer;Initial Catalog=Pubs;User Id=sa;Password=; "
cnn1.Open strCnn
Set rstSchema = cnn1.OpenSchema(adSchemaTables)
Do Until rstSchema.EOF
Debug.Print "Table name: " & _
rstSchema!TABLE_NAME & vbCr & _
"Table type: " & rstSchema!TABLE_TYPE & vbCr
rstSchema.MoveNext
Loop
rstSchema.Close
cnn1.Close
End Sub
'EndOpenSchemaVB
"chiki" <rpo@hotmail.co.il> wrote:
>
>How can I know how many tabels are in the database and what are they names?
>(in running time)
>
>
>thank you very much
>
>chiki
"chiki" <rpo@hotmail.co.il> wrote:
>
>How can I know how many tabels are in the database and what are they names?
>(in running time)
>
>
>thank you very much
>
>chiki
Use tabledefs.count if using DAO.