?
Solved

Converting UCHAR to char[] in C

Posted on 2003-03-12
3
Medium Priority
?
407 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Six Sigma Control Plans
Introduction to Processes

777 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