MS Access 64 bit the connection to Visual Foxpro - vba

After switching from Office 365 32 bit to Office 64 bit the connection to Visual Foxpro does not work anymore.
So with :
"Provider=Advantage OLE DB Provider; Data Source=D:ACCESSImport; ServerType=ADS_LOCAL_SERVER; TableType=ADS_VFP;"
and
Dim AdsGetCustRecordset As ADODB.Recordset
Set AdsGetCustRecordset = New ADODB.Recordset
AdsGetCustRecordset.Open "SELECT * FROM TABLE", objcon, adOpenDynamic, adLockPessimistic, adCmdText
Actually the access is possible. However with error messages from the Advantage Client Engine.
"exception code was generated when calling the user supplied callbackfuntion . it is being disabled"
Maybe someone can help me.
Many thanks in advance

Advantage Database has both a 32- and 64-bit drivers, make sure you have correct version. If you are not seeing the
ACE64.dll
ADSLOC64.dll
ADSOLEDB64.dll
AICU64.dll
AXCWS64.dll
That is probably why.

Related

Getting an E_OUTOFMEMORY when accessing an Access database with OLEDB

We have this VB.net code that connects to an MS Access Database and tries to insert a new entry:
Dim conn As New OleDbConnection
conn.ConnectionString = "Provider="Microsoft.ACE.OLEDB.16.0; Data Source=" & DATABASE_PATH & ";Jet OLEDB:Database Password=pass;"
conn.Open()
Dim SqlString As String = "INSERT INTO tblNotes" &
" ([NotesNumber" &
"], [NotesTitle" &
"], [HasAdditionalLogic" &
"], [TypeId]) Values (?,?,?,?)"
Dim cmd As New OleDbCommand(SqlString, conn)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("NotesNumber", 1234)
cmd.Parameters.AddWithValue("NotesTitle", "the title")
cmd.Parameters.AddWithValue("HasAdditionalLogic", False)
cmd.Parameters.AddWithValue("TypeId", 14)
cmd.ExecuteNonQuery()
conn.close()
Nothing too fancy, right?
This code worked fine with Access 2016 installed.
Now with the recent upgrade to Office 365 the line
cmd.ExecuteNonQuery()
causes this error:
'Microsoft.ACE.OLEDB.16.0' failed with no error message available, result code: E_OUTOFMEMORY(0x8007000E)
Googling for that error message lead to several ideas like using Integer instead of Long Integer in the database, but that did not help either.
And personally, I doubt that the root cause is a lack of memory because the machine has 32GB RAM installed and is set to 32GB of Virtual Memory. The process itself never uses more than 100MB, Windows Process Explorer tells us that the whole RAM uses about 5GB total. So I just cannot believe we are actually running out of memory here.
Any idea?
Update:
Okay, we seem to have found the underlying issue here.
You see this line:
cmd.Parameters.AddWithValue("TypeId", 14)
In the Access database, the field "TypeId" has been defined as a Primary Key of Data Type "AutoNumber" and Field Size "Long Integer".
Now, if we write the code like this:
cmd.Parameters.AddWithValue("TypeId", 14I)
it runs without an error, but as soon as we change it to:
cmd.Parameters.AddWithValue("TypeId", 14L)
we get the crash.
Let me state again that the code with a Long works fine with Access 2016, it crashes with the Access from Office 365.
I may be mistaken, but this seems like a bug in Access.
Of course we can now change all the app code from Long to Integer (or UInteger), but this seems like treating the symptoms instead of the root cause.
Can somebody confirm this? Or tell me why exactly this happens? Using a Long seems to be correct to me, using an Integer instead seems pretty wrong to me.
To anybody who might face the same problem: we "fixed" the issue by installing "Microsoft Access Database Engine 2010 Redistributable"
https://www.microsoft.com/en-US/download/details.aspx?id=13255
and then using
Microsoft.ACE.OLEDB.12.0
instead of
Microsoft.ACE.OLEDB.16.0
That did the trick.
The hint with .add instead of .addWithValue did not make any difference.

VB.net - Get error "Attempted to read or write protected memory..." since provider changed

That's my first post here, so please indicate me if there are some missing useful informations' to help to solve my problem.
Here is it:
I have a VB.net application using Access database (.mdb), which worked properly for years.
Because I'm using now Access Database Engine 2016 in 64-bits, I have changed my DB connection provider from Microsoft.Jet.OLEDB.4.0 (only available in 32-bits) to Microsoft.ACE.OLEDB.12.0. I've also unchecked in my app's properties "32-bits prefered" (translation from my French version of Visual Studio).
Since I did these changes (and only them), I often get the following error:
System.AccessViolationException: 'Attempted to read or write
protected memory. This is often an indication that other memory is
corrupt.
It appears (randomly) in different parts of the software, always at the line myConnection.Open()
Dim myConnection As OleDbConnection = New OleDbConnection(S7ConnString)
Try
myConnection.Open()
...
First new connection string with which I began to get this problem is:
Public S7ConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & DBPath & ";Jet OLEDB:Database Password=***;"
(where DBPath is a string for the Access .mdb file path)
After some searches, I've read that adding OLE DB Services=-1 could solve it. It improved speed of DB processes really much, but did not solved the problem.
Would you have any idea to solve this?
Thank you & Kind regards.
I have uninstalled Access Database Engine 2016 and installed 2010 64-bits version, and it seems to work correctly now.
Thank you for your suggestions, #Jimi, that helped me to solve this. I did not imagine "Microsoft.ACE.OLEDB.12.0" provider was not compatible with MS Access Database Engine 2016!

Can't connect to Access DB, neither with OleDB, DAO, etc

I want to read and write data from a CATIA macro to and from an Access DataBase. I've got Windows 10 and Office 2013 on it (64bit Windows).
Unfortunately I can't connect to that Access DataBase from VBA. (From VB.NET works fine)
I tried it all:
Various connection strings (JET.4.0, ACE.12.0) etc with ADODB
-> Error that Provider cant be found
Connection via DAO
-> Various other errors
Any idea why I cant connect?
I referenced all DLLs possible to reference, etc.
Only idea I have that theres a problem with Access 2013 32bit and the 64 bit Windows?
I tried from Excel with the following code (source), it works like a charm.
Sub test()
Dim cnn As ADODB.Connection 'Requieres reference to the Microsoft
Dim rs As ADODB.Recordset 'ActiveX Data Objects Library
Set cnn = CreateObject("adodb.Connection")
cnn.Open "DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\Users\someFolder\myDb.accdb;"
Set rs = cnn.Execute("SELECT * FROM versions")
While Not rs.EOF
Debug.Print rs(1), rs(2), rs(3)
rs.MoveNext
Wend
rs.Close
End Sub
if that doesn't work, the client PC may lack a piece of software ?

Link PostgreSQL to MS Access using ADO library via ODBC driver (DSN-less)

Hello :) I've searched Stackoverflow and Google for a lot of hours and would like to have a clear answer to my problem, because I got a little bit confused. I want to link a table from my PostgreSQL database to my MS Access frontend using VBA. Therefore I'm using the ADO library and installed the 32 bit ODBC driver for PostgreSQL. It works great if I use a connection string with a defined DSN, code looks like this:
Set conn = New ADODB.Connection
Dim strConnect As String
strConnect = "DSN=PostgreSQL35W;Database=...;UID=...;PWD=..."
conn.Open
But the thing is that I dont wan't to use a connection string with DSN, because I dont want to mess around with these DSNs, esspecially not in a distributed environment. Therefore I would like to use a DSN-less connection string. But it seems like that the ADO library doesn't support DSN-less connection strings while using the ODBC driver for PostgreSQL. Is that true?
Here's the code I used for the DSN-less connection:
Set conn = New ADODB.Connection
Dim strConnect As String
strConnect = "ODBC;Driver={PostgreSQL Unicode};Server=...;Port=5432;Database=...;UID=...;PWD=..;TABLE=...
I know there are a lot of threads about that topic, but I couldn't get a clear answer for it. So thank you very much in advance!

ADOBC Connection Fails on Windows 10 Machines Only

I'm fairly new to working with Access/VB (started 2 months ago) so bear with me.
I inherited a database that has an ADODB connection to Oracle that works perfect on the Windows 7 machines that it's been tested on (a total of 5), but gives the following error when tested on Windows 10 machines (total of 2). (All machines are running Access 2010).
Run-time Error '3709': The connection cannot be used to perform this operation. It is either closed or invalid in this context.
Here's the code:
Public Function PTMNConnect() As ADODB.Connection
Dim Cn As ADODB.Connection
Dim Conn As String
Conn = "DRIVER={Microsoft ODBC for Oracle};CONNECTSTRING=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)" & _
"(HOST=host)(PORT=port))(CONNECT_DATA=(SERVICE_NAME=PROD)));uid=username;pwd=password"
Set Cn = New ADODB.Connection
With Cn
.ConnectionString = Conn
.CursorLocation = adUseServer
.Open '**Errors Out on Open**
End With
Set PTMNConnect = Cn
End Function
I've been racking my brain and searching everywhere for a possible solution to this for the past two days with no luck.
Here's what I've tried/verified so far based on other posts I'd seen:
Verified that the Oracle client was installed
Ensured that the Path variable contained the necessary paths
Verified the references and file paths are the same on all machines
Any insight or references that you may be able to provide would be greatly appreciated!
I was able to come up with a fix for this!
It turns out that Windows 7 and Windows 10 have different versions of the {Microsoft ODBC for Oracle} driver which I believe is what was causing the error. I decided to use the Oracle supplied driver (which remains the same for each PC) rather than the Microsoft supplied driver (which, as I found out, varies).
Replacing the Conn string from above with the following code fixed my issue. (This route requires an existing DSN):
Conn = "DRIVER={Oracle in OraClient11g_home1}; Dbq=DSN_TNSServiceName; uid=username; pwd=password"