Link to home
Start Free TrialLog in
Avatar of foxycharlie
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,uUser,SQL_NTS,uPassword,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
Avatar of gj62
gj62

lstrcpy(uchar, "this is the string");
ASKER CERTIFIED SOLUTION
Avatar of gj62
gj62

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.