473,395 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Linking access tables?

Is there any way to programmatically link access tables using vb.net
Jul 21 '05 #1
10 5967
What do you mean by Linking as this is an Access term to mean "getting data
from another database application"
"Job Lot" <Jo****@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
Is there any way to programmatically link access tables using vb.net

Jul 21 '05 #2
Hi John

I am not talking about relationships. I want to create a link to a table
which belongs to a separate mdb. In access we right click in Tables windows
and use “Link Tables” option to create a link to table which resides in some
other db.

Is it possible to create such link programmatically?

"JohnFol" wrote:
What do you mean by Linking as this is an Access term to mean "getting data
from another database application"
"Job Lot" <Jo****@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
Is there any way to programmatically link access tables using vb.net


Jul 21 '05 #3
..Net assemblies are NOT MDB files, nor does Access use .Net hence why the
comment does not make sense.

To perform the equivalent of a right click in the tables window, open the
Server Explorer, right click Data Connections and add new connection. You
can then navigate to the MDB.

To programatitcally do this look at the ADO.Net documentation and look for
OleDBConnection


"Job Lot" <Jo****@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
Hi John

I am not talking about relationships. I want to create a link to a table
which belongs to a separate mdb. In access we right click in Tables
windows
and use "Link Tables" option to create a link to table which resides in
some
other db.

Is it possible to create such link programmatically?

"JohnFol" wrote:
What do you mean by Linking as this is an Access term to mean "getting
data
from another database application"
"Job Lot" <Jo****@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
> Is there any way to programmatically link access tables using vb.net


Jul 21 '05 #4
On Thu, 6 Jan 2005 16:19:01 -0800, "Job Lot" <Jo****@discussions.microsoft.com> wrote:

Is there any way to programmatically link access tables using vb.net

Yes, you can use ADOX (Microsoft ADO Ext 2.x for DDL and Security) via interop. The below example
links to a table in an Access database:

Sub CreateAttachedAccessTableWithADOX()

Dim ADOXTable As New ADOX.Table
Dim ADOXCatalog As New ADOX.Catalog
Dim ADOConnection As New ADODB.Connection

Try

ADOConnection.Open("Provider=Microsoft.Jet.OLEDB.4 .0;" & _
"Data Source=e:\My Documents\db1.mdb;" & _
"Jet OLEDB:Engine Type=4;")

ADOXCatalog.ActiveConnection = ADOConnection

ADOXTable.Name = "Table11Linked"
ADOXTable.ParentCatalog = ADOXCatalog
ADOXTable.Properties("Jet OLEDB:Link Provider String").Value = "MS Access;DATABASE=E:\My
Documents\AccessDB.mdb"
ADOXTable.Properties("Jet OLEDB:Remote Table Name").Value = "Table11"
ADOXTable.Properties("Jet OLEDB:Create Link").Value = True
ADOXCatalog.Tables.Append(ADOXTable)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
ADOConnection.Close()
End Try

End Sub
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Jul 21 '05 #5
Thanks Paul that worked.

"Paul Clement" wrote:
On Thu, 6 Jan 2005 16:19:01 -0800, "Job Lot" <Jo****@discussions.microsoft.com> wrote:

¤ Is there any way to programmatically link access tables using vb.net

Yes, you can use ADOX (Microsoft ADO Ext 2.x for DDL and Security) via interop. The below example
links to a table in an Access database:

Sub CreateAttachedAccessTableWithADOX()

Dim ADOXTable As New ADOX.Table
Dim ADOXCatalog As New ADOX.Catalog
Dim ADOConnection As New ADODB.Connection

Try

ADOConnection.Open("Provider=Microsoft.Jet.OLEDB.4 .0;" & _
"Data Source=e:\My Documents\db1.mdb;" & _
"Jet OLEDB:Engine Type=4;")

ADOXCatalog.ActiveConnection = ADOConnection

ADOXTable.Name = "Table11Linked"
ADOXTable.ParentCatalog = ADOXCatalog
ADOXTable.Properties("Jet OLEDB:Link Provider String").Value = "MS Access;DATABASE=E:\My
Documents\AccessDB.mdb"
ADOXTable.Properties("Jet OLEDB:Remote Table Name").Value = "Table11"
ADOXTable.Properties("Jet OLEDB:Create Link").Value = True
ADOXCatalog.Tables.Append(ADOXTable)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
ADOConnection.Close()
End Try

End Sub
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)

Jul 21 '05 #6
One more question

Before creating link, how can I check to see whether or not link already
exists? In my application I get an error if link is already there in the
database.

Thanks


"Paul Clement" wrote:
On Thu, 6 Jan 2005 16:19:01 -0800, "Job Lot" <Jo****@discussions.microsoft.com> wrote:

¤ Is there any way to programmatically link access tables using vb.net

Yes, you can use ADOX (Microsoft ADO Ext 2.x for DDL and Security) via interop. The below example
links to a table in an Access database:

Sub CreateAttachedAccessTableWithADOX()

Dim ADOXTable As New ADOX.Table
Dim ADOXCatalog As New ADOX.Catalog
Dim ADOConnection As New ADODB.Connection

Try

ADOConnection.Open("Provider=Microsoft.Jet.OLEDB.4 .0;" & _
"Data Source=e:\My Documents\db1.mdb;" & _
"Jet OLEDB:Engine Type=4;")

ADOXCatalog.ActiveConnection = ADOConnection

ADOXTable.Name = "Table11Linked"
ADOXTable.ParentCatalog = ADOXCatalog
ADOXTable.Properties("Jet OLEDB:Link Provider String").Value = "MS Access;DATABASE=E:\My
Documents\AccessDB.mdb"
ADOXTable.Properties("Jet OLEDB:Remote Table Name").Value = "Table11"
ADOXTable.Properties("Jet OLEDB:Create Link").Value = True
ADOXCatalog.Tables.Append(ADOXTable)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
ADOConnection.Close()
End Try

End Sub
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)

Jul 21 '05 #7
I got it working as

For Each table As ADOX.Table In ADOXCatalog.Tables
If table.Name = tableName Then
Exit Sub
End If
Next

While I was iterating through tables collection of ADOX.Catalog, I noticed
there were actually more tables in the collection than displayed in tables
windows of access db. Most of these tables started with TMP. Where did these
tables come from?

"Job Lot" wrote:
One more question

Before creating link, how can I check to see whether or not link already
exists? In my application I get an error if link is already there in the
database.

Thanks


"Paul Clement" wrote:
On Thu, 6 Jan 2005 16:19:01 -0800, "Job Lot" <Jo****@discussions.microsoft.com> wrote:

¤ Is there any way to programmatically link access tables using vb.net

Yes, you can use ADOX (Microsoft ADO Ext 2.x for DDL and Security) via interop. The below example
links to a table in an Access database:

Sub CreateAttachedAccessTableWithADOX()

Dim ADOXTable As New ADOX.Table
Dim ADOXCatalog As New ADOX.Catalog
Dim ADOConnection As New ADODB.Connection

Try

ADOConnection.Open("Provider=Microsoft.Jet.OLEDB.4 .0;" & _
"Data Source=e:\My Documents\db1.mdb;" & _
"Jet OLEDB:Engine Type=4;")

ADOXCatalog.ActiveConnection = ADOConnection

ADOXTable.Name = "Table11Linked"
ADOXTable.ParentCatalog = ADOXCatalog
ADOXTable.Properties("Jet OLEDB:Link Provider String").Value = "MS Access;DATABASE=E:\My
Documents\AccessDB.mdb"
ADOXTable.Properties("Jet OLEDB:Remote Table Name").Value = "Table11"
ADOXTable.Properties("Jet OLEDB:Create Link").Value = True
ADOXCatalog.Tables.Append(ADOXTable)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
ADOConnection.Close()
End Try

End Sub
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)

Jul 21 '05 #8
On Sun, 9 Jan 2005 18:33:02 -0800, "Job Lot" <Jo****@discussions.microsoft.com> wrote:

I got it working as

For Each table As ADOX.Table In ADOXCatalog.Tables
If table.Name = tableName Then
Exit Sub
End If
Next

While I was iterating through tables collection of ADOX.Catalog, I noticed
there were actually more tables in the collection than displayed in tables
windows of access db. Most of these tables started with TMP. Where did these
tables come from?


Don't think I've seen those before but it sounds like they're internal temporary tables. You can
probably identify them by checking the Type property of the ADOX Table object.
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Jul 21 '05 #9
thanks paul. another question though :-)

I have a friend who is trying to create access db in asp.net, he do asp.net
in a text editor as he doesn’t have vs. How can he add references to
Microsoft ADO Ext 2.7 for DDL and Security? Is there an “Import Namespace=”
equivalent?
"Paul Clement" wrote:
On Sun, 9 Jan 2005 18:33:02 -0800, "Job Lot" <Jo****@discussions.microsoft.com> wrote:

¤ I got it working as
¤
¤ For Each table As ADOX.Table In ADOXCatalog.Tables
¤ If table.Name = tableName Then
¤ Exit Sub
¤ End If
¤ Next
¤
¤ While I was iterating through tables collection of ADOX.Catalog, I noticed
¤ there were actually more tables in the collection than displayed in tables
¤ windows of access db. Most of these tables started with TMP. Where did these
¤ tables come from?
¤

Don't think I've seen those before but it sounds like they're internal temporary tables. You can
probably identify them by checking the Type property of the ADOX Table object.
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)

Jul 21 '05 #10
On Mon, 10 Jan 2005 14:13:03 -0800, "Job Lot" <Jo****@discussions.microsoft.com> wrote:

thanks paul. another question though :-)

I have a friend who is trying to create access db in asp.net, he do asp.net
in a text editor as he doesnt have vs. How can he add references to
Microsoft ADO Ext 2.7 for DDL and Security? Is there an Import Namespace=
equivalent?


You have to use late binding. See the following:

http://aspnet101.com/aspnet101/tutorials.aspx?id=27
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Jul 21 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John South | last post by:
I have an Access 2000 front end that I wish to work with a SQL Server 2000 database by means of Linked tables. Do I have to use an ODBC connection to SQL Server? It seems to be the only option...
2
by: Jeff Pritchard | last post by:
Some time ago I am sure I came across something that said this was possible, though it doesn't seem to work. A client wants to replace an Access back-end with SQL Server tables. We have tried...
14
by: diskoduro | last post by:
Hi!! Years ago I built a database to control the production of a little factory. The users wanted to work in a Windows Net workgroup so I created an mdb with all the tables and data an after...
0
by: gasturbtec | last post by:
please help im new at access programming and i just got this project dropped in my lap because the old programmer quit. i've been doing ok so far but now i need to add code to an existing database...
18
by: Mark P | last post by:
I have a bit of vb code that uses Tables.Append to programatically link tables from Oracle and DB2 datasources. The problem I am having on some client machines is that the link will take anywhere...
5
by: Christoph Sticksel | last post by:
Hi, I'm having problems with attaching two tables stored in an SQL Server 2000 to an Access 97 database. It worked well for all other tables except those two. This is what I did: Choose the...
2
by: Matthew Wells | last post by:
Good morning... I have an Access front end that uses SQL Server linked tables. SQL Server uses Windows authentication. I have one Windows group that all Access users are a member of. I added...
2
by: TheTamdino | last post by:
One of the things that is common between most genealogy databases is that they will have one screen were you log all the information for a given person and then (maybe) have a link to a source...
3
by: ARC | last post by:
I'm having trouble here with Access 2007 and connecting to a different database. The code below works great IF the previous back-end database connection is still present and you are trying to...
7
by: Salad | last post by:
I am converting an application from A97 to A2003. I have 2 tables created by another application as a Foxpro.dbf. The table has no index. The connect string in A97 is FoxPro...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.