Today is...
Friday, August 23, 2019
Welcome to Control.com, the global online
community of automation professionals.
Featured Video...
Featured Video
A demonstration of EtherCAT control of linear motors using the CTC EtherCAT master.
Our Advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive
Citect SCADA and SQL Data Transfer
Transferring data from SQL server to textbox in Citect SCADA

Hi,

I want to connect to SQL server and get data from it. I show it on textbox in Citect SCADA 2018. I have this code for this task. Data does not show on textbox. Please say your idea for me.


INT
FUNCTION
GetNames()
INT hSQL;
STRING sName;
INT Status;

hSQL = SQLConnect( "DSN=impaytere_ss" );
IF hSQL <> -1 THEN
Status = SQLExec( hSQL,"SELECT CNAME FROM FETISH WHERE SURNAME = 'Jumpy' " );
IF Status = 0 THEN
WHILE SQLNext( hSQL ) = 0 DO
sName = SQLGetField( hSQL, "CNAME" );

// whatever you wish to do with this data...

END;
SQLEnd( hSQL );

ELSE
Message( "Error", SQLErrMsg(), 48 );
END;

ELSE
Message( "Error", SQLErrMsg(), 48 );
END;
RETURN sName
SQLDisconnect( hSQL );
END

A bit late... but where are you calling this function from? Both SQLConnect and SQLExec are BLOCKING functions and cannot be called from foreground tasks. E.g. you cannot call this from a text label's Text expression. This must be called from something like a button press, or an event.