Hi - I'm trying to work out a way to loop through (or just get a list
of) all of the tables in an SQL Server (2005) database from Access.
Based on the name of the table, I will then proceed to do some action
with it. I want to use a DSNless connection. I have searched but
haven't been able to sort it out just yet. Any ideas?
(Note: I tried with DAO but my OpenDatabase kept failing - I think it
prefers a DSN and I'm trying DSNless. I also can connect with ADO but
then can't seem to figure out how to get a list of available tables). 8 14699 Ka********@gmail.com wrote in news:1167267102.836756.85820
@f1g2000cwa.googlegroups.com:
Hi - I'm trying to work out a way to loop through (or just get a list
of) all of the tables in an SQL Server (2005) database from Access.
Based on the name of the table
<snips>
I also can connect with ADO but
then can't seem to figure out how to get a list of available tables).
Public Sub GetTableNames()
Dim c As ADODB.Connection
Dim r As ADODB.Recordset
Dim f As ADODB.Field
Set c = New ADODB.Connection
With c
..Provider = "sqloledb.1"
With .Properties
..Item("Data Source") = "server"
..Item("Initial Catalog") = "database"
..Item("PassWord") = "password"
..Item("User ID") = "userid"
End With
..Open
Set r = .OpenSchema(adSchemaTables, _
Array(Empty, Empty, Empty, "TABLE"))
With r
' show the field names
' information available
For Each f In .Fields
Debug.Print f.Name
Next f
Debug.Print
' show the table names
While Not .EOF
Debug.Print .Fields("TABLE_NAME"), .Fields("TABLE_TYPE")
.MoveNext
Wend
End With
End With
End Sub
--
Lyle Fairfield
On 27 Dec 2006 16:51:42 -0800, Ka********@gmail.com wrote:
I think Lyle's solution is more elegant than mine, but you could
certainly link sysobjects table to your MDB, and then select from it.
I believe tables have a Type='U'.
-Tom.
>Hi - I'm trying to work out a way to loop through (or just get a list of) all of the tables in an SQL Server (2005) database from Access. Based on the name of the table, I will then proceed to do some action with it. I want to use a DSNless connection. I have searched but haven't been able to sort it out just yet. Any ideas?
(Note: I tried with DAO but my OpenDatabase kept failing - I think it prefers a DSN and I'm trying DSNless. I also can connect with ADO but then can't seem to figure out how to get a list of available tables).
Great - thx! - works perfectly. I am a little unclear on how one would
determine what arguments are available in the Array( ) portion of the
OpenSchema line. I will continue to look into it, but if you feel like
providing additional info, great! Thanks again though.
On Dec 27, 8:24 pm, Lyle Fairfield <lylefairfi...@aim.comwrote:
Kandar7...@gmail.com wrote in news:1167267102.836756.85820
@f1g2000cwa.googlegroups.com:
Hi - I'm trying to work out a way to loop through (or just get a list
of) all of the tables in an SQL Server (2005) database from Access.
Based on the name of the table<snips>
I also can connect with ADO but
then can't seem to figure out how to get a list of available tables).Public Sub GetTableNames()
Dim c As ADODB.Connection
Dim r As ADODB.Recordset
Dim f As ADODB.Field
Set c = New ADODB.Connection
With c
.Provider = "sqloledb.1"
With .Properties
.Item("Data Source") = "server"
.Item("Initial Catalog") = "database"
.Item("PassWord") = "password"
.Item("User ID") = "userid"
End With
.Open
Set r = .OpenSchema(adSchemaTables, _
Array(Empty, Empty, Empty, "TABLE"))
With r
' show the field names
' information available
For Each f In .Fields
Debug.Print f.Name
Next f
Debug.Print
' show the table names
While Not .EOF
Debug.Print .Fields("TABLE_NAME"), .Fields("TABLE_TYPE")
.MoveNext
Wend
End With
End With
End Sub
--
Lyle Fairfield
Thanks! - this options works as well. I will explore this table
further...seems like it could be useful in many ways.
On Dec 27, 9:33 pm, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On 27 Dec 2006 16:51:42 -0800, Kandar7...@gmail.com wrote:
I think Lyle's solution is more elegant than mine, but you could
certainly link sysobjects table to your MDB, and then select from it.
I believe tables have a Type='U'.
-Tom.
Hi - I'm trying to work out a way to loop through (or just get a list
of) all of the tables in an SQL Server (2005) database from Access.
Based on the name of the table, I will then proceed to do some action
with it. I want to use a DSNless connection. I have searched but
haven't been able to sort it out just yet. Any ideas?
(Note: I tried with DAO but my OpenDatabase kept failing - I think it
prefers a DSN and I'm trying DSNless. I also can connect with ADO but
then can't seem to figure out how to get a list of available tables).- Hide quoted text -- Show quoted text -
Ka********@gmail.com wrote in
news:11**********************@a3g2000cwd.googlegro ups.com:
Great - thx! - works perfectly. I am a little unclear on how one
would determine what arguments are available in the Array( ) portion
of the OpenSchema line. I will continue to look into it, but if you
feel like providing additional info, great! Thanks again though.
The fields were:
1. TABLE_CATALOG
2. TABLE_SCHEMA
3. TABLE_NAME
4. TABLE_TYPE
5. TABLE_GUID
6. DESCRIPTION
7. TABLE_PROPID
8. DATE_CREATED
9. DATE_MODIFIED
The qualifier was
Array(Empty, Empty, Empty, "TABLE")
which specified
1. no criterion for TABLE_CATALOG
2. no criterion for TABLE_SCHEMA
3. no criterion for TABLE_NAME
4. TABLE_TYPE="Table" (which excluded the System Tables); We might have
specified "ALIAS", "TABLE", "SYNONYM","SYSTEM TABLE","VIEW","GLOBAL
TEMPORARY", "LOCAL TEMPORARY" or "SYSTEM VIEW"
We could have included more Emptys for
5. TABLE_GUID
6. DESCRIPTION
7. TABLE_PROPID
8. DATE_CREATED
9. DATE_MODIFIED
but that was unnecessary as ADO OpenSchema defaults to Empty after the last
Field referenced (so no Array will return all information available).
We could replace any Empty with an Equal Criterion for that Field.
If we specify
adSchemaProviderSpecific
and a
SchemaID
we may get other fields; I have not explored this.
--
Lyle Fairfield
Thanks - very interesting and useful. chrs
On Dec 28, 1:18 pm, Lyle Fairfield <lylefairfi...@aim.comwrote:
Kandar7...@gmail.com wrote innews:11**********************@a3g2000cwd.googleg roups.com:
Great - thx! - works perfectly. I am a little unclear on how one
would determine what arguments are available in the Array( ) portion
of the OpenSchema line. I will continue to look into it, but if you
feel like providing additional info, great! Thanks again though.The fields were:
1. TABLE_CATALOG
2. TABLE_SCHEMA
3. TABLE_NAME
4. TABLE_TYPE
5. TABLE_GUID
6. DESCRIPTION
7. TABLE_PROPID
8. DATE_CREATED
9. DATE_MODIFIED
The qualifier was
Array(Empty, Empty, Empty, "TABLE")
which specified
1. no criterion for TABLE_CATALOG
2. no criterion for TABLE_SCHEMA
3. no criterion for TABLE_NAME
4. TABLE_TYPE="Table" (which excluded the System Tables); We might have
specified "ALIAS", "TABLE", "SYNONYM","SYSTEM TABLE","VIEW","GLOBAL
TEMPORARY", "LOCAL TEMPORARY" or "SYSTEM VIEW"
We could have included more Emptys for
5. TABLE_GUID
6. DESCRIPTION
7. TABLE_PROPID
8. DATE_CREATED
9. DATE_MODIFIED
but that was unnecessary as ADO OpenSchema defaults to Empty after the last
Field referenced (so no Array will return all information available).
We could replace any Empty with an Equal Criterion for that Field.
If we specify
adSchemaProviderSpecific
and a
SchemaID
we may get other fields; I have not explored this.
--
Lyle Fairfield
Make a Pass-Thru query to your database and use:
Exec SP_Tables
As your query.
(If you don't already know this, be sure to set the ODBC connection
string in the Properties of the query.)
See the SQL BOL for more information on SP_Tables, and you might also
want to look at SP_Columns for a list of the columns in a table.
On 27 Dec 2006 16:51:42 -0800, Ka********@gmail.com wrote:
>Hi - I'm trying to work out a way to loop through (or just get a list of) all of the tables in an SQL Server (2005) database from Access. Based on the name of the table, I will then proceed to do some action with it. I want to use a DSNless connection. I have searched but haven't been able to sort it out just yet. Any ideas?
(Note: I tried with DAO but my OpenDatabase kept failing - I think it prefers a DSN and I'm trying DSNless. I also can connect with ADO but then can't seem to figure out how to get a list of available tables).
--
Drive C: Error. (A)bort (R)etry (S)mack The Darned Thing
On 28 Dec 2006 08:45:27 -0800, Ka********@gmail.com wrote:
sysobjects and the many other system tables and the several catelog
views (don't forget these; handy summary views!) are well documented
in SQL Server Books Online.
-Tom.
>Thanks! - this options works as well. I will explore this table further...seems like it could be useful in many ways.
On Dec 27, 9:33 pm, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
>On 27 Dec 2006 16:51:42 -0800, Kandar7...@gmail.com wrote:
I think Lyle's solution is more elegant than mine, but you could certainly link sysobjects table to your MDB, and then select from it. I believe tables have a Type='U'.
-Tom.
>Hi - I'm trying to work out a way to loop through (or just get a list of) all of the tables in an SQL Server (2005) database from Access. Based on the name of the table, I will then proceed to do some action with it. I want to use a DSNless connection. I have searched but haven't been able to sort it out just yet. Any ideas?
>(Note: I tried with DAO but my OpenDatabase kept failing - I think it prefers a DSN and I'm trying DSNless. I also can connect with ADO but then can't seem to figure out how to get a list of available tables).- Hide quoted text -- Show quoted text -
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sue Adams |
last post by:
I actually have two issues/questions:
I have an autonumber field in an access db table that I grab and later use to update a record in another table withing the same db.
The code I use to get...
|
by: jason |
last post by:
Access 2000:
I have a customer-inventory table I need to loop through and compile a list
of all the inventory items the customer is tracking. The problem I am
finding is that a simple loop...
|
by: addi |
last post by:
All,
I will be eternally greatful if someone can provide snippet of code,
URL or reference material that shows how to display data in a "n
colums * n rows" format.
I am new to ASP and have...
|
by: dSchwartz |
last post by:
I need help adding a column to a dataset, but its a little bit more
complicated then just that. Here's the situation: I have many xml
files in one directory, each which represent a newsletter. I...
|
by: Mark Harrison |
last post by:
HOWTO: Integrating Posgresql queries into an event loop.
Mark Harrison
mh@pixar.com
May 27, 2004
Problem
-------
The commonly used postgresql APIs will block until completed.
| |
by: jlee |
last post by:
I'm pretty much a newbie on mysql, and I need some help.
I am running mysql Ver 12.22 Distrib 4.0.24, for portbld-freebsd5.4
(i386) on a server hosting an active website.
The site's developer...
|
by: david |
last post by:
I try to use "for" loop to retrieve and assign values in web form. The code
is in the following. But it can not be compiled.
What I want to do is:
txtQ1.Text =...
|
by: david |
last post by:
I try to use "for" loop to assign textbox control ID to a textbox variable in
server side codebehind for a web form. But I met some problem.
What I want to do is solving the following-like code by...
|
by: fniles |
last post by:
I am using VB.NET 2003, SQL 2000, and SqlDataAdapter.
For every record in tblA where colB = 'abc', I want to update the value in
colA.
In VB6, using ADO I can loop thru the recordset,set the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |