|
-
Jan 23rd, 2004, 07:55 PM
#1
Thread Starter
Frenzied Member
Querying a Access Database
Can someome possibly post an example to do what I want.
I am using the openschema method of a ADO connection to itterate through the list of queries in a database.
What I wan to extract is the list of fields the query is using and the associated table that the field comes from.
I have already done this for the list of tables but I cannot use the same code for the queries (or as in the openschema method, "VIEW").
O have already looked at the examples in the MSDN but they only seem to list all the available VIEWS, not the actual fields.
Thanks.
Mega.
"If at first you don't succeed, then skydiving is not for you"
-
Jan 26th, 2004, 07:39 AM
#2
Member
This is taken from an old Database Analyser app i wrote a while back.
I've removed a lot of the code (it also displayed keys, field sizes, etc) but it should give you an idea of how to go about doing what you need. I know you already have your code set up to get the tables, but you could use the same routine below to do the same thing (just look for type "TABLE" instead of "VIEW")
VB Code:
Private cat As New ADOX.Catalog
Private tbl As New ADOX.Table
For Each tbl In cat.Tables
If InStr(1, tbl.Name, "MSys", vbTextCompare) = 0 And tbl.Type = "VIEW" Then
txtOutput = txtOutput & tbl.Name & vbCrLf
For i = 0 To tbl.Columns.Count - 1
txtOutput = txtOutput & vbTab & tbl.Columns(i).Name
Next i
txtOutput = txtOutput & vbCrLf
End If
Next tbl
-
Jan 26th, 2004, 08:54 AM
#3
Thread Starter
Frenzied Member
Ok, thanks. Another question though.Does this list the associated table that the field in the query comes from ?
e.g.
Query Name : QryCountCalls
Fields : Call ID
Table name : Call Details
Fields : Call Count
Table name : None (Expression variable).
Do you know what I mean?
Mega.
"If at first you don't succeed, then skydiving is not for you"
-
Jan 26th, 2004, 01:59 PM
#4
Lively Member
Thers a free OpenSchema gui in adoanywhere that exposes all enums.
here is a link to .net in case you need it in future http://support.microsoft.com/default...b;EN-US;309488
adoanywhere open schema gui
Mike Collier
Free ADO & DotNet Tools and Source
AdoAnywhere

-
Jan 26th, 2004, 06:36 PM
#5
Thread Starter
Frenzied Member
Thanks,
I have enough to go on now. 
Mega.
"If at first you don't succeed, then skydiving is not for you"
-
Jan 28th, 2004, 06:56 PM
#6
Thread Starter
Frenzied Member
Ok,
I now have a follow up question for this.
I can now itterate through the queries and list the columns in the query, however, if the query requires a parameter to be passed, I get errors.
I am going through loads of queries and I don't know which ones need parameters and how many. Is there anyway of getting the code to ignore this and give me the column name anyway?
Mega.
"If at first you don't succeed, then skydiving is not for you"
-
Jan 29th, 2004, 11:37 AM
#7
Thread Starter
Frenzied Member
"If at first you don't succeed, then skydiving is not for you"
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
|