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

Change ODBC Link Provider String in Access DB using ADOX in VB.NET

I am attempting to change the ODBC Link Provider String in an Access
database linked to an Oracle server using ADOX in VB.NET.

I created some code using the example from post:
http://groups.google.com/groups?q=Re...4ax.com&rnum=1

My code simply replaces the DSN, UID, PWD and DBQ values in the
ADOXTable.Properties("Jet OLEDB:Link Provider String").Value string
and then I try to set ADOXTable.Properties("Jet OLEDB:Link Provider
String").Value to my new string.

I get the Error:
System.Runtime.InteropServices.COMException (0x80004005):
ODBC--connection to 'C:\DSN\new.dsn' failed.
at ADOX.Property.set_Value(Object pVal)
at test.frmTest.RefreshLinkedTablesWithADOX() in frmTest.vb:line
302

This is the Code:

Sub RefreshLinkedTablesWithADOX()

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

Try

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

ADOXCatalog.ActiveConnection = ADOConnection

For Each ADOXTable In ADOXCatalog.Tables
If ADOXTable.Type = "PASS-THROUGH" Then
LinkProviderString = ADOXTable.Properties("Jet OLEDB:Link " &
_
Provider String").Value
'''''''''
' Manipulate LinkProviderString to replace DSN, UID, PWD and
DBQ
' for new DSN values.
'''''''''
ADOXTable.Properties("Jet OLEDB:Link " & _
"Provider String").Value = LinkProviderString
End If
Next
Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
ADOConnection.Close()
End Try

End Sub

I tried to shorten some lines of code so they won't wrap.

There is no security on these access databases as we created them
in-house as a front end query engine for our Oracle database.

Does anyone have any ideas?
Nov 21 '05 #1
2 8637
Tim,

It is ODBC and it is Oracle,

I advise you to ask this in the newsgroup

Adonet
news://msnews.microsoft.com/microsof...amework.adonet

Web interface:

http://communities2.microsoft.com/co...amework.adonet

I give you much more change there for more answers

Cor

"Tim Frawley" <ti*********@fishgame.state.ak.us> schreef in bericht
news:bf*************************@posting.google.co m...
I am attempting to change the ODBC Link Provider String in an Access
database linked to an Oracle server using ADOX in VB.NET.

I created some code using the example from post:
http://groups.google.com/groups?q=Re...4ax.com&rnum=1

My code simply replaces the DSN, UID, PWD and DBQ values in the
ADOXTable.Properties("Jet OLEDB:Link Provider String").Value string
and then I try to set ADOXTable.Properties("Jet OLEDB:Link Provider
String").Value to my new string.

I get the Error:
System.Runtime.InteropServices.COMException (0x80004005):
ODBC--connection to 'C:\DSN\new.dsn' failed.
at ADOX.Property.set_Value(Object pVal)
at test.frmTest.RefreshLinkedTablesWithADOX() in frmTest.vb:line
302

This is the Code:

Sub RefreshLinkedTablesWithADOX()

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

Try

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

ADOXCatalog.ActiveConnection = ADOConnection

For Each ADOXTable In ADOXCatalog.Tables
If ADOXTable.Type = "PASS-THROUGH" Then
LinkProviderString = ADOXTable.Properties("Jet OLEDB:Link " &
_
Provider String").Value
'''''''''
' Manipulate LinkProviderString to replace DSN, UID, PWD and
DBQ
' for new DSN values.
'''''''''
ADOXTable.Properties("Jet OLEDB:Link " & _
"Provider String").Value = LinkProviderString
End If
Next
Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
ADOConnection.Close()
End Try

End Sub

I tried to shorten some lines of code so they won't wrap.

There is no security on these access databases as we created them
in-house as a front end query engine for our Oracle database.

Does anyone have any ideas?

Nov 21 '05 #2


Thank you for your quick response. When I posted the message I received
a DNS error after I submitted the post. I was not sure if this had gone
through.

I have resolved my problem. I finally realized I could not put the File
DSN link into the linked table string. This is what caused the error.

After looking through the properties for a linked table I realized that
a table that is linked through a file DSN was simply placing the driver
value and never looked at the file DSN again. I have since created the
code to update our Access databases using this approach and now we no
longer depend on a DSN at all.

The primary concern was the DSN held the driver versions we use for
Oracle. We have to standardize all our clients with the same driver but
that should be a small price to pay. :)
Thanks again,

Tim Frawley

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #3

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

Similar topics

11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
11
by: DJJ | last post by:
I am using the MySQL ODBC 3.51 driver to link three relatively small MySQL tables to a Microsoft Access 2003 database. I am finding that the data from the MySQL tables takes a hell of a long time...
0
by: Mike Knight | last post by:
I have the following code in an Excel 2003 module that creates a query in MS Access 2003. The created query can then be opened from Access. In Access, right-mouse clicking in design mode, in...
6
by: Claudia Fong | last post by:
Hello, I'm using the sql statement below to create a new table from an old one. But I found a little problem with that. In my old table DEP2004, I have one field's property allow zero length...
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...
1
by: RLN | last post by:
RE: Access 2003 using WinXP SP2 Problem: When I start up my app I double click either one of my two Oracle tables in the table list, it asks for an id and pass. I need them to be linked at...
1
by: mikerudy | last post by:
I have an 3rd-party application that uses a SQL back-end, but uses Access 2000 (linked tables all using the same DSN) as an intermediary. We recently upgraded from SQL 7 to SQL 2005, which went...
3
by: Vee007 | last post by:
Following is my code: Dim objCatalog As ADOX.Catalog Dim objTableLink As ADOX.Table Dim objADOConnection As ADODB.Connection Try objADOConnection = New...
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
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
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,...
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
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...

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.