Reputation: 31
I am very new to programming so I will require some extra help on figuring this out. I have a VB .NET application that provides an Add-In for a 64-Bit application. The task I am trying to accomplish is to open a connection to a 32-Bit MS Access database and lookup data from a table. Where this falls apart is the fact that a 64-Bit application cannot connect with a 32-Bit database. You can probably tell from my explanation that I barely know what I am talking about.
Everything I have researched on this topic comes to the same conclusion that I need to use an interprocess communication but do not explain how this is done and what I am required to do to make this happen.
Here is my connection setup in the VB .Net application:
Public Class MSDatabase
Dim provider As String
Dim dataFile As String
Dim connString As String
Public myConnection As OleDbConnection = New OleDbConnection
Public dr As OleDbDataReader
Public Sub LoadDatabase()
provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source ="
dataFile = "\\server3\databases\Quotes.accdb"
connString = provider & dataFile
myConnection.ConnectionString = connString
End Sub
Public Function LookUpPart(D As Double, E As Double, F As Double, G As Double, Grade As String) As Boolean
myConnection.Open()
Dim str As String
str = "SELECT PartNumber, D, E, F, G, Grade FROM Parts"
Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
dr = cmd.ExecuteReader
While dr.Read()
If D = dr("D") And E = dr("E") And F = dr("F") And G = dr("G") And Grade = dr("Grade") Then
Return True
End If
End While
myConnection.Close()
Return False
End Function
End Class
This fails when I try to open the connection with the error message stating that the provider Microsoft.ACE.OLEDB.12.0 is not registered on the local machine.
What I would like to know is how to use interprocess communication to set this up as a 32-Bit application called from my 64-Bit application.
Any help is greatly appreciated!
Upvotes: 1
Views: 2492
Reputation: 31
Thanks to jmcilhinney for their help with solving this issue. Read the comments under the question to see how we arrive at this solution.
SOLUTION: Using interprocess communication through a TCP socket connection you can pass data back and forth regardless of the bittedness of the host and client. In this case, the 64-Bit vb .net program written for an Add-In to another software can setup a TcpClient
that uses Process.Start
to first run a TcpListener
in a console application developed for the x86 platform and then send the listener information for the database communication. The listener being a 32-Bit console application is able to find and use the 32-Bit provider for the OLEDB connection and pull the needed data from the Access DB. The data is then sent back to the client in the 64-Bit application.
For the TCP socket connection you can use a simple YouTube tutorial on a client/server TCP connection for vb.net.
For sending data I used a delimiter so that the data could easily be separated on the other end using Split
.
Upvotes: 2
Reputation: 1218
We had the same problem and solved it by following the the instructions found here (look for the section titled "The Solution"). There you'll find a link to the appropriate driver you need to install.
The install seems to be necessary because with Office 2010 Microsoft changed the driver for accessing Access, Excel and so on. So it's not a problem with your code, but the environment it runs in.
Upvotes: 0