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?