foxycharlie
asked on
Converting UCHAR to char[] in C
I am currently working on a program in C which connects to a database. The code which does this is as follows:
UCHAR uSQL[] = "SELECT * FROM customer where cnumber = '2'";
//connecting to the database
retcode = SQLConnect(hDBC,uDatabase, SQL_NTS,uU ser,SQL_NT S,uPasswor d,SQL_NTS) ;
//retcode will hold ‘1’ if connection is established else ’-1’
printf("Connecting to the database\n");
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
retcode = SQLAllocStmt (hDBC, &hStmt);
retcode = SQLPrepare (hStmt, uSQL, sizeof (uSQL));
retcode = SQLExecute (hStmt);
SQLBindCol(hStmt, 2, SQL_C_CHAR, sName, sizeof(sName), &cbName);
//Get first record
retcode = SQLFetch (hStmt);
while (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
strcpy(cust.sEmail,sEmail) ;
retcode = SQLFetch (hStmt);
The SQL is stored in UCHAR. However, I need to dynamically generate the SQL. I was hoping to do this using char[] arrays i.e. stings then convert this to UCHAR. But how do I do this???
Any help would be much appreciated
Charlie
UCHAR uSQL[] = "SELECT * FROM customer where cnumber = '2'";
//connecting to the database
retcode = SQLConnect(hDBC,uDatabase,
//retcode will hold ‘1’ if connection is established else ’-1’
printf("Connecting to the database\n");
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
retcode = SQLAllocStmt (hDBC, &hStmt);
retcode = SQLPrepare (hStmt, uSQL, sizeof (uSQL));
retcode = SQLExecute (hStmt);
SQLBindCol(hStmt, 2, SQL_C_CHAR, sName, sizeof(sName), &cbName);
//Get first record
retcode = SQLFetch (hStmt);
while (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
strcpy(cust.sEmail,sEmail)
retcode = SQLFetch (hStmt);
The SQL is stored in UCHAR. However, I need to dynamically generate the SQL. I was hoping to do this using char[] arrays i.e. stings then convert this to UCHAR. But how do I do this???
Any help would be much appreciated
Charlie
lstrcpy(uchar, "this is the string");
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
foxycharlie:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.