All this code worked in SQL Windows 2005.1
My issue is with retrieving my data when it is encrypted (using Windows CryptoAPI). It will not pull out the information properly. If I un-encrypt my date, my code pulls it out properly (e.g. 01272007). However, if i encrypt the data: ÞÏpè>œ<“ - the information retrieved is retrieved as: xxpx>x<x (the x's show up as boxes in any message box). It grabs the normal characters (the p, and the greater than and less than symbols but it can't get the special characters) (all characters are legal ANIS and UNICODE characters (http://www.alanwood.net/demos/ansi.html)
Anyone else have this issue? Anyone have a solution? Anyone have a suggestion on what to try?
Here is the Stored Procedure used to pull out the last logon date out of the ADMIN database:
Code: Select all
Call SqlStore(hSqlProcedure, 'SYSADM.GetLog',
'Procedure: GetLog STATIC
Parameters
Receive String: strLog
Local Variables
Actions
On Procedure Execute
Call SqlImmediate(\'select LAST_LOGON_DATE FROM MISC_SECURITY into :strLog\')
Call SqlClearImmediate()')
Code: Select all
Call SalSetBufferLength(strDate, 500)
Set strDate = SpRetStrBindStr('ADMIN/' || str_USER_ID_1 || '/' || str_PASSWORD, 'SYSADM.GetLog',strDate)
Code: Select all
LPWSTR CStoredProcsApp::SpRetStrBindStr (LPWSTR lpstrConnectString,LPWSTR lpstrStoredProcedure, LPWSTR lpstrBinds)
{
SQLTCUR hSqlHandle;
unsigned char nLength;
unsigned char nFetRet;
char strData[256];
char *lp = strData;
size_t i;
static wchar_t wstrData[256];
char mbsConnectString[256];
char mbsStoredProcedure[256];
char mbsBinds[256];
char buffer[256];
wcstombs_s(&i, mbsConnectString, (size_t)256, lpstrConnectString, (size_t)256);
wcstombs_s(&i, mbsStoredProcedure, (size_t)256, lpstrStoredProcedure, (size_t)256);
wcstombs_s(&i, mbsBinds, (size_t)256, lpstrBinds, (size_t)256);
if (sqlcncA(&hSqlHandle, (SQLTDAP) mbsConnectString, 0) == 0)
{
if (sqlretA(hSqlHandle, (unsigned char *) mbsStoredProcedure, 0) == 0)
{
if (sqlbnn (hSqlHandle,1,(SQLTDAP) &strData, sizeof (strData),0,SQLPSTR) == 0)
{
sqlssb(hSqlHandle, (SQLTSLC)1, SQLPSTR, (SQLTDAP) &strData, 254, 0, &nLength,&nFetRet);
sqlexe(hSqlHandle);
sqlfet(hSqlHandle);
}
}
sqldis(hSqlHandle);
}
mbstowcs_s(&i, wstrData, (size_t)256, strData, strlen(strData)+1);
return wstrData;
}