473,549 Members | 2,556 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

relinking tables in Access db using VB.NET and ADOX

I am trying to relink some Oracle tables in an Access database via VB.NET and ADOX. I receive the following error when executing the cat.ActiveConne ction link

"Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

Here is my code

Dim cat As ADOX.Catalog = New ADOX.Catalo
Dim tbl As ADOX.Tabl
Dim OracleConn As String = "Provider=MSDAO RA.1;Data Source=xzy;User ID=xyz;Password =xyz

Tr
cat.ActiveConne ction = "Provider=Micro soft.Jet.OLEDB. 4.0;" &
"Data Source=c:\datab ases\xyz.mdb;" &
"Jet OLEDB:Engine Type=5

For Each tbl In cat.Table
'Check to make sure the table is a linked tabl
If tbl.Type = "LINK" The
tbl.Properties( "Jet OLEDB:Create Link").Value = Tru
tbl.Properties( "Jet OLEDB:Link Provider String").Value = OracleCon
tbl.Properties( "Jet OLEDB:Cache Link Name/Password").Valu e = Tru
End I
Nex
Catch ex As Exceptio
sr.WriteLine(ex .Message
End Tr

Any ideas

Thank

Nov 20 '05 #1
2 7822
Hi,

I tryed this once, but after a whiel I gave up: I was able to relink most of
them, but not all, and I didn't found out why not all. If you find it,
please post your code here! I owuld really appreciate it!

This is what I tryed:
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

"Randy" <an*******@disc ussions.microso ft.com> wrote in message
news:F9******** *************** ***********@mic rosoft.com...
I am trying to relink some Oracle tables in an Access database via VB.NET and ADOX. I receive the following error when executing the
cat.ActiveConne ction link:
"Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."
Here is my code:

Dim cat As ADOX.Catalog = New ADOX.Catalog
Dim tbl As ADOX.Table
Dim OracleConn As String = "Provider=MSDAO RA.1;Data Source=xzy;User ID=xyz;Password =xyz"
Try
cat.ActiveConne ction = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=c:\datab ases\xyz.mdb;" & _
"Jet OLEDB:Engine Type=5"

For Each tbl In cat.Tables
'Check to make sure the table is a linked table
If tbl.Type = "LINK" Then
tbl.Properties( "Jet OLEDB:Create Link").Value = True
tbl.Properties( "Jet OLEDB:Link Provider String").Value = OracleConn tbl.Properties( "Jet OLEDB:Cache Link Name/Password").Valu e = True End If
Next
Catch ex As Exception
sr.WriteLine(ex .Message)
End Try

Any ideas?

Thanks

Nov 20 '05 #2
On Tue, 27 Apr 2004 07:21:01 -0700, "Randy" <an*******@disc ussions.microso ft.com> wrote:

¤ I am trying to relink some Oracle tables in an Access database via VB.NET and ADOX. I receive the following error when executing the cat.ActiveConne ction link:
¤
¤ "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."
¤
¤ Here is my code:
¤
¤ Dim cat As ADOX.Catalog = New ADOX.Catalog
¤ Dim tbl As ADOX.Table
¤ Dim OracleConn As String = "Provider=MSDAO RA.1;Data Source=xzy;User ID=xyz;Password =xyz"
¤
¤ Try
¤ cat.ActiveConne ction = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
¤ "Data Source=c:\datab ases\xyz.mdb;" & _
¤ "Jet OLEDB:Engine Type=5"
¤
¤ For Each tbl In cat.Tables
¤ 'Check to make sure the table is a linked table
¤ If tbl.Type = "LINK" Then
¤ tbl.Properties( "Jet OLEDB:Create Link").Value = True
¤ tbl.Properties( "Jet OLEDB:Link Provider String").Value = OracleConn
¤ tbl.Properties( "Jet OLEDB:Cache Link Name/Password").Valu e = True
¤ End If
¤ Next
¤ Catch ex As Exception
¤ sr.WriteLine(ex .Message)
¤ End Try
¤

Probably a connection string issue. Are you using either the Microsoft or Oracle ODBC driver for
your Link Provider String?
Paul ~~~ pc******@amerit ech.net
Microsoft MVP (Visual Basic)
Nov 20 '05 #3

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

Similar topics

10
5983
by: Job Lot | last post by:
Is there any way to programmatically link access tables using vb.net
4
2726
by: gaffar | last post by:
Sir, I am developing an application in vb.net and the backend database is ms-access. i have created ms-access databse and tables and assigned primary keys to the tables through the vb.net application(code is below). Now my problem is i want delete one record from master table, that deleted record automatically deleted from
11
4585
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...
4
4100
by: Oceania | last post by:
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
9
8267
by: Peter | last post by:
Hello£¬everyone, My program will collect a testing machine's data ,save the data and deal with the data everyday. I want to use vb.net to create database, add and delete tables or modify the records in the database. Is it possible to create a SQL Server database using vb.net? I know I can use vb.net and ADOX to create a Access database....
18
2448
by: Ken Kazinski | last post by:
Does anyone know of a good example for creating a access database and then tables within that database. All the examples I have found so far use a SQL database. Thanks, Ken
1
1764
by: gaffar | last post by:
Sir, I am developing an application in vb.net and the backend database is ms-access. i have created ms-access databse and tables and assigned primary keys to the tables through the vb.net application(code is below). Now my problem is i want delete one record from master table, that deleted record automatically deleted from
1
3330
by: racquetballguy | last post by:
Hi I have data tables in the form of 200612... 200701... 200702... etc The user specifies the start date and end date in an input form ie: 12/25/2006 - 1/10/2007.
13
4497
by: Arno R | last post by:
Hi all, I am deploying an A2k app to users with different versions of Access. Using Access 2000 the relinking on startup (on deploying a new frontend or when backend has changed) is very fast. It takes about 4-5 seconds to relink some 50 tables. (I am relinking, not refreshing) Using Access 2003 the relinking is very slow compared with...
0
7526
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...
0
7457
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7723
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. ...
0
7965
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...
1
5375
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...
0
3504
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1949
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 we have to send another system
1
1063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
771
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...

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.