Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Converting UCHAR to char[] in C

Posted on 2003-03-12
3
Medium Priority
?
414 Views
Last Modified: 2012-05-04
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
0
Comment
Question by:foxycharlie
  • 2
3 Comments
 
LVL 6

Expert Comment

by:gj62
ID: 8123862
lstrcpy(uchar, "this is the string");
0
 
LVL 6

Accepted Solution

by:
gj62 earned 200 total points
ID: 8123876
Sorry, that wasn't too clear...

char sqlString[50];

/* set sqlString equal to whatever you want...  copy into uSQL by ...*/

lstrcpy(uSQL,sqlString);
0
 

Expert Comment

by:CleanupPing
ID: 9447187
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.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Starting up a Project
Screencast - Getting to Know the Pipeline

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question