473,385 Members | 1,329 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,385 software developers and data experts.

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 4080
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.OleDb

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(ByVal 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.Connection

'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.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & strDirFile

'OleDBConn.Open()

ADOConnection.Open("Provider=Microsoft.Jet.OLEDB.4 .0;Data Source=" &
strDirFile & ";Persist Security Info=False")

'Dim rst As New ADODB.Recordset

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

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

'rst.MoveFirst()

SyncLock (GetType(clsDB))

'Try

cat.ActiveConnection = ADOConnection

Try

'MessageBox.Show(cat.Tables.Count)

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.WriteLine(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).Command

Try

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

'87 properties in het totaal!!!

If cmd.Properties("Jet OLEDB:ODBC Pass-Through Statement").Value = 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.Properties("Jet OLEDB:Pass Through Query Connect String").Value)

'78

'cmd.Properties(87)

End If

Catch ex As System.Runtime.InteropServices.COMException

Console.WriteLine(ex.Message)

Catch ex As Exception

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

End Try

'MsgBox(cmd.CommandType())

'MsgBox(cmd.Properties("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.OpenDatabase(strDirFile)

'ldb = New DAO.DBEngine

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

'Dim r As Integer

'For r = 0 To ldb.QueryDefs.Count - 1

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

'End If

'Next

'Catch ex As Exception

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

'Finally

'End Try

End SyncLock

RaiseEvent Refresh_Ready(Me.strDB, intT, intQ)

cat.ActiveConnection = Nothing

ADOConnection.Close()

cat = Nothing

tbl = Nothing

cmd = Nothing

prc = Nothing

End Sub

End Class



"Oceania" <da****@datec.com-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
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...
2
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...
1
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...
3
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...
11
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...
0
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...
12
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...
2
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...
1
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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...

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.