|
-
Mar 5th, 2006, 08:04 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] View Tables in a Database
After opening my connection, I want to view the tables found in my database and display them on screen. Can anybody please help me do that?
Thanx
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
-
Mar 5th, 2006, 08:10 PM
#2
Re: View Tables in a Database
If your using ADO, you can use 'Schema'. A search will yeild examples.
-
Mar 5th, 2006, 08:17 PM
#3
Thread Starter
Frenzied Member
Re: View Tables in a Database
Yes I'm using ADO. is it the openschema function in the connection string? How do i do it?
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
-
Mar 5th, 2006, 08:17 PM
#4
Re: View Tables in a Database
Not every db supports Schema so using ADOX could be a better choice.
-
Mar 5th, 2006, 08:20 PM
#5
Thread Starter
Frenzied Member
Re: View Tables in a Database
well what i actually want to do is to view the tables found in my Access, SQL Server Database and also the worksheets in Microsoft excel
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
-
Mar 5th, 2006, 08:34 PM
#6
Thread Starter
Frenzied Member
Re: View Tables in a Database
I'm going to view these tables in a treeview then if a user clicks on a table, the fields will be displayed in a listbox
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
-
Mar 5th, 2006, 08:46 PM
#7
Fanatic Member
Re: View Tables in a Database
noister
<advertising link removed by moderator>
-
Mar 5th, 2006, 08:57 PM
#8
Thread Starter
Frenzied Member
Re: View Tables in a Database
i've seen the link, ive tried it but unfortunately, its not working
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
-
Mar 5th, 2006, 09:04 PM
#9
Re: View Tables in a Database
Set references to ADO and also ADO Ext. ... and try this sample:
VB Code:
Private Sub Command1_Click()
'============================
Dim tbl As ADOX.Table
Dim cat As ADOX.Catalog
Dim cnn As ADODB.Connection
Dim i%
Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\biblio.mdb;"
Set cat = New ADOX.Catalog
Set cat.ActiveConnection = cnn
For Each tbl In cat.Tables
Combo1.AddItem que.Name
Next tbl
cnn.Close
Set cat = Nothing
Set cnn = Nothing
End Sub
-
Mar 5th, 2006, 09:29 PM
#10
Thread Starter
Frenzied Member
Re: View Tables in a Database
thankx Rhino. First, it didn't work due to the que.Name
what i did is i just changed que to tbl which is defined as a table in adox. only one thing, I have one excel worksheet in my excel file called was2. when i run that code, it returnce two values, was2$(which is the expected output) and was2$_. is this a normal scenario in adox or theres is something missing in the code.
my first approach for this is to filter the returned values if the last character is an (_). if it is, i wont display it but if not, i will.
is there any other better option for this?
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
-
Mar 5th, 2006, 09:39 PM
#11
Thread Starter
Frenzied Member
Re: View Tables in a Database
well i just filter the tablenames by looking for the $ sign at the end of the value returned. if the last character of the value is $ then it is one of the worksheets in excel and it will display it. ir not it wont, thanks Rhino for the help
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
-
Mar 5th, 2006, 09:40 PM
#12
Re: View Tables in a Database
 Originally Posted by d3gerald
thankx Rhino. First, it didn't work due to the que.Name...
That's because what I posted is shrinked version of much more complex sample... Glad you figured it out on your own.
-
Mar 5th, 2006, 09:59 PM
#13
Thread Starter
Frenzied Member
Re: [RESOLVED] View Tables in a Database
am i on the right track on my solution above, or theres another way of doing it?
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
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
|