I think I am missing the concept behind the unassigned char. I understand that UCHAR stands for unassigned char. I am not used to this format however. I am using it to connect and run sql commands to MS SQL Server db.
My problem is, I want a combination of different string variables to make one large string and pass that as my sql statement. I am familiar with combining strings like this:
Code:
//using string.h namespace std;
string char1 ="Hello ";
string char2= "World";
char1 += char2;
//char1 now equals "Hello World"
//and to pass this value to file or ouput
strcpy(somestring, char1.c_str());
However how can I take a variable type of UCHAR and a character of arrays that can be passed to a handle such as:
Code:
char buff[128] = "Select Routename, LotID, Location FROM sublot WHERE LotID like '05101182025734%'";
UCHAR szSqlStr[128];
//open db code ect.... and then combine variables and execute
//currently trying to do this without success
sprintf((char *)szSqlStr,"%p",&buff);
cout <<szSqlStr<<endl;
/*//it looks correct on screen but I get garbage back, and I know the statement works because when I set the szSqlStr equal to this directly it works */
//part that is returning junk
// Prepare the SQL statement by assigning it to the statement handle
retcode = SQLPrepare (hStmt, szSqlStr, sizeof (szSqlStr));
// Execute the SQL statement handle
retcode = SQLExecute (hStmt);
// Project only column 1 which is the models
SQLBindCol (hStmt, 1, SQL_C_CHAR, szRoutename, sizeof(szRoutename), &cbRoutename);
SQLBindCol (hStmt, 2, SQL_C_CHAR, szLotID, sizeof(szLotID), &cbLotID);
SQLBindCol (hStmt, 3, SQL_C_CHAR, szLocation, sizeof(szLocation), &cbLocation);
// Get row of data from the result set defined above in the statement
retcode = SQLFetch (hStmt);
cout <<szRoutename<<endl;
cout <<szLotID<<endl;
cout <<szLocation<<endl;
Sorry if that took too long to get out... Thanks for any help, this is driving me nutz!