Vikneshan

Problem getting PI values into MATLAB

Discussion created by Vikneshan on Oct 29, 2010
Latest reply on Nov 1, 2010 by Ahmad Fattahi

Hi everyone, i had a post from an earlier date, i managed to resolves the connection issues with MATLAB turned out to be an issue with OLEDB not being installed correctly, but i have another issue right now. I m currently running this one a server 2008 rev2 , with matlab 64bit

 

ArchiveValue = PI_ArchiveValue('servername.XXXXX','cdt158','*-1h')
Warning: ActiveX - unsupported VARIANT type encountered
> In adodbquery at 40
  In PI_ArchiveValue at 36

ArchiveValue =

     []

 


Here is my code

function Output = PI_ArchiveValue(server,tag,timestamp,cn)

dbUserName='XXX';
dbPassword='XXX';
dbSource='XXXX';
archive='piinterp2';

% Detect if an existing connection was passed
if nargin<4
    % Build connection string

   cnstr = ['Provider=PIOLEDB;User ID=' dbUserName ';Password=' dbPassword ';Data Source=' dbSource ';Initial Catalog = ' archive ';Connection Timeout =60'];
    % Open connection
    cn=adodbcn(cnstr);
end

% Query to execute
sql=strcat('SELECT tag, time, value FROM piarchive..piinterp2 WHERE tag = ''',tag,''' AND time = ''',timestamp,'''');

Outcomes