I've got code (below) to read data from a MS Access table into MATLAB, via an ActiveX server, that works very nicely. I'm now trying to use the same code to read data from an Access linked table connected to SQL Server, but am getting an error:
Invoke Error, Dispatch Exception: Source: DAO.Database Description: You must use the dbSeeChanges option with OpenRecordset when accessing a SQL Server table that has an IDENTITY column. Help File: jeterr40.chm Help Context ID: 4c5966
So, the table in question has an IDENTITY column, and I need to specify the 'dbSeeChanges' option with OpenRecordset. My question is, how do I specify this option? I can see plenty of examples online of how to do it in VBA, but none that would be MATLAB-compatible. Here's my code:
% Setup environment
app = 'Access.Application';
DBAddress = 'O:\testData.accdb';
% Load an Activex server for Access
try
svr = actxGetRunningServer(app);
catch err
svr = actxserver(app);
end
% Load the required database file
accessDB = svr.DBEngine.OpenDatabase(DBAddress);
% Query the database for the required records
sql_query = 'SELECT * FROM dbo_PatientMeasurementResults;';
rs = accessDB.OpenRecordset(sql_query);
I've tried the obvious, but this does not work:
rs = accessDB.OpenRecordset(sql_query,'dbSeeChanges');
dbSeeChangesis a number (Const dbSeeChanges = 512 (&H200)). Have you triedrs = accessDB.OpenRecordset(sql_querry, dbSeeChanges);? (or with the constant 512)dbSeeChanges = 512gave me anInvoke Error (Description: Invalid argument.)error, but interestingly 'dbSeeChanges = 4fixed the problem. Haven't got to the bottom yet of why that worked, however!