Here is my code on WinCC :
[code] char strSQL[500];
DWORD time;
//**************************************************************************************************************
#pragma code ("oleaut32.dll")
float VariantTimeToSystemTime(DATE vtime, LPSYSTEMTIME lpSystemTime);
#pragma code ()
//**************************************************************************************************************
#define DBSource "@DatasourceNameRT"
#pragma code ("DB.dll")
WINBASEAPI BOOL WINAPI DBConnect (HANDLE*, char*, CMN_ERROR*); // open
WINBASEAPI BOOL WINAPI DBExecuteDirect_hdsn(HANDLE, char*, CMN_ERROR*); // execute
WINBASEAPI BOOL WINAPI DBDisConnect(HANDLE, DWORD, CMN_ERROR*); // close
#pragma code ()
HANDLE hDSN=NULL; // DSN
CMN_ERROR ErrStruct;
BOOL bRes=TRUE;
#define EXEC_SQL bRes=bRes&&DBExecuteDirect_hdsn( hDSN, strSQL, &ErrStruct );
// how to select ?//**************************************************************************************************************
bRes=DBConnect ( &hDSN, GetTagChar(DBSource), &ErrStruct);
if (bRes)
{
sprintf( strSQL,"select max (RecTime) as NU from TbHFlow_DT");
EXEC_SQL;
printf("%s \r\n",strSQL);
time=DateToTimeT(); // here must be my variable
}
if( hDSN != NULL ) bRes=(bRes&&DBDisConnect( hDSN, 0, &ErrStruct) );
hDSN=NULL;
return 0;
}[/code]
And so here is trouble I know how to execute SQL but I don't know how can I get a result from query.
I also can't find more description about DB.dll functions.
Also here is StackOverflow question mirror : http://stackoverflow.com/questions/5711971/how-to-get-select-some-data-from-sql-query-using-db-dll-on-wincc
Follow us on