473,597 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

relink access tables using vb.net coding.... Help

Hi All,

I did try using the sample code from the ADO.net forum to link one
table, it is working fine. But, I got a problem when I tried to link
all tables (20 tables)... Please help, thank you....

Rgds....
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #1
4 4100
Cor
Hi Oceania,

Maybe it is better what you want to archieve because that ADOX code you are
using is for me real not understandable anymore. (But as I see it, I think
it is incomplete, I see not any recordset or something other to get the data
in it).

So tell us what you try to do.

And I think there are not much people who want to learn that again.

Cor
Nov 20 '05 #2
Hi,

Some time ago I tryed the same thing. I had to refresh a whole bunch of
query's and table's in a whole bunch of Access-databases. I looked some days
on the internet for solutions, tryed really a lot, but nothing worked really
fine. I had some solution that for some reason didn't work with every
table/query, and I never foudn out why. I ended up doing this in Access,
hehe.

Maybe you can do something with my VB.NET code? Maybe you can find usefull
things in it or improve it?

If you findsomething that really works, can you post it please?

Pieter


Option Explicit On

Imports System.Runtime. InteropServices

Imports System.Data.Ole Db

Public Class clsDB

Public strPath As String

Public strDB As String

Public intLen As Integer

Public strConn As String

Public strOld As String

Public strDirFile As String

Public Event Refresh_Ready(B yVal strDB As String, ByVal intTa As Integer,
ByVal intQu As Integer)

Public Event Refreshing_Item (ByVal strText As String)

Public Sub subRefresh()

'On Error Resume Next

Dim ADOConnection As New ADODB.Connectio n

'Dim OleDBConn As New OleDbconnection

Dim cat As New ADOX.Catalog

Dim tbl As New ADOX.Table

Dim prc As ADOX.Procedure

Dim strProcName As String

Dim cmd As ADODB.Command

Dim intT, intQ As Integer

intT = 0

intQ = 0

'OleDBConn.Conn ectionString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=" & strDirFile

'OleDBConn.Open ()

ADOConnection.O pen("Provider=M icrosoft.Jet.OL EDB.4.0;Data Source=" &
strDirFile & ";Persist Security Info=False")

'Dim rst As New ADODB.Recordset

'rst = ADOConnection.E xecute("SELECT * FROM dbo_oas_company ")

'rst = ADOConnection.E xecute("SELECT * FROM dbo_T_Select")

'rst.MoveFirst( )

SyncLock (GetType(clsDB) )

'Try

cat.ActiveConne ction = ADOConnection

Try

'MessageBox.Sho w(cat.Tables.Co unt)

For Each tbl In cat.Tables

Try

If tbl.Type = "PASS-THROUGH" Then

If UCase(Left(tbl. Properties("Jet OLEDB:Link Provider String").Value( ),
intLen)) = UCase(strOld) Then

RaiseEvent Refreshing_Item ("Refreshing table: " & strDB & " - " & tbl.Name)

intT = intT + 1

tbl.Properties( "Jet OLEDB:Link Provider String").Value( ) = strConn

End If

End If

Catch ex As Exception

RaiseEvent Refreshing_Item ("Error Refreshing table: " & strDB & " - " &
tbl.Name)

End Try

Next

Catch ex As System.Runtime. InteropServices .COMException

Console.WriteLi ne(ex.Message)

Catch ex As Exception

RaiseEvent Refreshing_Item ("Error Refreshing tables: " & strDB)

End Try

Try

For Each prc In cat.Procedures

strProcName = prc.Name

cmd = New ADODB.Command

cmd = cat.Procedures( strProcName).Co mmand

Try

'MsgBox(intX & " - " & cmd.CommandText )

'87 properties in het totaal!!!

If cmd.Properties( "Jet OLEDB:ODBC Pass-Through Statement").Val ue = True Then
'79

If UCase(Left(cmd. Properties("Jet OLEDB:Pass Through Query Connect
String").Value, intLen + 5)) = UCase("ODBC;" & strOld) Then

RaiseEvent Refreshing_Item ("Refreshing query: " & strDB & " - " &
strProcName)

intQ = intQ + 1

cmd.Properties( "Jet OLEDB:Pass Through Query Connect String").Value = "ODBC;
" & strConn

End If

'MsgBox(cmd.Pro perties("Jet OLEDB:Pass Through Query Connect String").Value)

'78

'cmd.Properties (87)

End If

Catch ex As System.Runtime. InteropServices .COMException

Console.WriteLi ne(ex.Message)

Catch ex As Exception

RaiseEvent Refreshing_Item ("Error Refreshing query: " & strDB & " - " &
strProcName)

End Try

'MsgBox(cmd.Com mandType())

'MsgBox(cmd.Pro perties("Jet OLEDB:Link Provider String").Value( ))

Next

Catch ex As Exception

RaiseEvent Refreshing_Item ("Error Refreshing query's: " & strDB)

End Try

'Dim wrk As DAO.Workspace

'Dim ldb As DAO.Database

'Dim tdf As DAO.TableDef

'Dim qdf As DAO.QueryDef

'wrk = New DAO.DBEngine

'ldb = wrk.OpenDatabas e(strDirFile)

'ldb = New DAO.DBEngine

'ldb.Connect = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & strDirFile

'Dim r As Integer

'For r = 0 To ldb.QueryDefs.C ount - 1

'If (ldb.QueryDefs( r).Type = "eeer") And (Left(ldb.Query Defs(r).Connect ,
intLen) = strOld) Then

'End If

'Next

'Catch ex As Exception

'MessageBox.Sho w(ex.Message & ex.Source, "Exception - " & strDB)

'Finally

'End Try

End SyncLock

RaiseEvent Refresh_Ready(M e.strDB, intT, intQ)

cat.ActiveConne ction = Nothing

ADOConnection.C lose()

cat = Nothing

tbl = Nothing

cmd = Nothing

prc = Nothing

End Sub

End Class



"Oceania" <da****@datec.c om-dot-fj.no-spam.invalid> wrote in message
news:40******** @Usenet.com...
Hi All,

I did try using the sample code from the ADO.net forum to link one
table, it is working fine. But, I got a problem when I tried to link
all tables (20 tables)... Please help, thank you....

Rgds....
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 20 '05 #3
Hi Cor,

This is what I really try to do:

I always have a front-end empty database namely dbtest, and I also
have a permanent back-end namely dbbend what contains about 20
tables. And, everytime the users open the application, it will create
the link from dbtest to dbbend. Then, these linked will drop when the
user logged out the application. Hope it make sense... Thank you..
Rgds,
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #4
Hi Cor,

This is what I really try to do:

I always have a front-end empty database namely dbtest, and I also
have a permanent back-end namely dbbend what contains about 20
tables. And, everytime the users open the application, it will create
the link from dbtest to dbbend. Then, these linked will drop when the
user logged out the application. Hope it make sense... Thank you..
Rgds,
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #5

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

Similar topics

3
24014
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked tables in the database where the code resides. If we move the database with the data tables to a new directory, the links are no longer valid. I tried to update the links by changing the Connect property and refreshing: Set td = db.TableDefs(0)...
2
1917
by: PeteCresswell | last post by:
My code for DoCmd.TransferDatabase stopped working after applying the update in question. Seems like the last argument (optional: SaveLogInID) can no longer be specified when DataBaseType="Microsoft Access". At least I removed that argument and my code worked. Seems logical and sounds like they've been letting me slide on my existing code and that Q823718 plugged a hole.
1
1781
by: sparks | last post by:
At first I thought I could just delete the tables and import the tables. BUT my tables have relationships and I can not delete a table with relations. So that only deleted the non relational tables and imported them. Now I am trying to relink the exported tables. this is the code I am using Public Function ReLink() As Boolean On Error Resume Next Dim astrTableNames(1000) As String Dim iintTableNames As Integer
3
2150
by: Jim | last post by:
I have a database with a front and back end setup as follows: Front: \\nt\database\NewDB\Stats.mdb = forms, reports, queries Back: "\\nt\database\NewDB\StatsData.mdb" = tables When the front is opened, I want to check and see if all the tables that are in the back end are currently linked to the front end... is
11
4588
by: DraguVaso | last post by:
Hi, I want to make a small application in VB.NET that relinks all the query's and tables in an Access database that are linked via ODBC to an SQL Server. It must be able to relink all the tables and query's to a given databse, on a given sql server with given login and password. Aybody knows how to do that, or better: has a sample application doing this? Thanks in advance!
0
1711
by: DraguVaso | last post by:
Hi, I need to relink a whole bunch of Access-Linked-Tables and Pass-Through-Query's to another ODBC with VB.NET I foudn alreaddy how to relink the Tables, and I thought the query's woudl be likewise, but I just can't find how to do it. For the tables this works:
12
4736
by: lesperancer | last post by:
I've got two MDBs, that due to size, security, etc, need to be kept separate quotation configurator (there will be more of these in the future) so within quotation.mdb, I linked all the tables that configurator.mdb uses I created a reference to configurator.mdbm using full path name I open a 'configurator' form, and away to work I go
2
2456
by: cranfan | last post by:
I'm using a relink method.It works fine but i have a question about making it work fast. If .Tables(tdfRelink.name).Type = "LINK" Then in this line i put a breakpoint and look for the table names(tdfRelink.name) but i see it includes my queries too.It checks my queries too for linking and it makes it work slower.Is it necessary or is it possible to pass linking queries or am i worng about that
1
2502
by: Coni | last post by:
Hello, I am following steps to implement security on access 2003 through distribution: I have split the database and I am trying to distribute it: I have copied the back end file and Security.mdw to a shared network directory. Map each user's PC to the shared network directory. However, I am stuck at this step which is to use the Linked Table Manager to relink the master copy of the database to the mapped drive.
0
7959
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8263
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8379
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8021
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5842
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5421
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3917
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1226
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.