If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > get db tables names and their columns

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-31-03, 11:52
edal11 edal11 is offline
Registered User
 
Join Date: Jan 2003
Posts: 4
get db tables names and their columns

Basically I want to have a treeview and a listview populated by tables that belong to the database that the user is currently browsing. It's some sort of primitive sybase central, or sql central.
Do you have any ideas on how to do this???
Oh, I'm trying to do this in vb or powerbuilder. Any other suggestions on other visual languages are also welcome!
Please help....
Reply With Quote
  #2 (permalink)  
Old 01-31-03, 15:39
Memnoch1207 Memnoch1207 is offline
Registered User
 
Join Date: Jan 2003
Location: Midwest
Posts: 138
Haven't work much with listview and treeview, but the sql statement to return all tables in the database is:

Note: This is for SQL Server
SELECT * FROM sysobjects WHERE type = 'U'
Reply With Quote
  #3 (permalink)  
Old 01-31-03, 20:17
playernovis playernovis is offline
Registered User
 
Join Date: Nov 2002
Location: San Francisco
Posts: 251
you can get tables and columns for almost any data source using ADOX

you can find list of many connection strings here http://www.able-consulting.com/ADO_Conn.htm


VB sample and MS Access Data Source

Sub ShowColumns()

Dim myAdoX As Object
Dim i As Integer
Dim j As Integer
Dim myConnection As String

Set myAdoX = CreateObject("ADOX.Catalog")
myConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\winnt\desktop\db1.mdb;" & _
"User Id=admin;" & _
"Password="

myAdoX.ActiveConnection = myConnection

For i = 0 To myAdoX.Tables.Count - 1
Debug.Print myAdoX.Tables(i).Name
For j = 0 To myAdoX.Tables(i).Columns.Count - 1
Debug.Print " - " & myAdoX.Tables(i).Columns(j).Name
Next
Next

End Sub


jiri
Reply With Quote
  #4 (permalink)  
Old 02-01-03, 00:02
edal11 edal11 is offline
Registered User
 
Join Date: Jan 2003
Posts: 4
Letīs say I use ADOX, after deploying my project must ADOX be installed on the compueter I plan to test my executable?

It seems to be a pretty easy solution, just for curiosity, is there another way without using ADO or ADOX??

Thanks for the advice!
Reply With Quote
  #5 (permalink)  
Old 02-03-03, 11:32
playernovis playernovis is offline
Registered User
 
Join Date: Nov 2002
Location: San Francisco
Posts: 251
you can use what Memnoch1207 recommends. If you plan to use just sybase as a backend, it will work just fine.....

on the other side, I haven't seen so many PCs without ADOx 2.1 - ADO is part of MS Office2000 and part of Win2k and WinXP. You can download it for free from www.microsoft.com/data and easily deploy on PCs..... setup.exe has some hidden switches....

jiri


you can use very old DAO - it has TABLEDEFS collection ......
or you can play with pure ODBC... http://msdn.microsoft.com/library/de...ns_in_odbc.asp
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On