Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CString Problem

Status
Not open for further replies.

OneSource

Programmer
Jun 18, 2002
22
US
Hi and thanks for reading.

I'm having a problem with a CString variable. For some reason, it is truncating the string that I assign to the variable. When I checked the length of the variable after the assignment, it was 252 characters. Does anyone know why this is happening? I thought that a CString variable could hold much more data than that.

Thanks.
 
Here's my code:
Code:
CString					sz_sqlString = "";
sz_sqlString = "INSERT INTO UserTable (UserName, Password, Address, City, State, ZipCode, Country, HomePhone, WorkPhone, CellPhone, Pager, Message) VALUES (TRIM('" + m_UserName + "'), TRIM('" + m_PassWord + "'), TRIM('" + m_Address + "'), TRIM('" + m_City + "'), TRIM('" + m_State + "'), TRIM('" + m_Zip + "'), TRIM('" + m_Country + "'), TRIM('" + m_HomePhone + "'), TRIM('" + m_WorkPhone + "'), TRIM('" + m_CellPhone + "'), TRIM('" + m_Pager + "'), TRIM('" + m_Message + "')";
Everytime I check the length of sz_sqlString after the above line of code, it comes back as 255.[nosmiley]Any ideas?[bigears]
 
I figured it out. The problem was that the debugger displays only 255 characters [evil] .... so I couldn't see the error in my SQL statement. [3eyes]
 
Sorry that I didn't reply fast enough. I was already away my computer when you reply, guess we are on a different time zone. Anyway glad that you found out the problem.

Since you're using MFC, you can use TRACE() to output sz_sqlString in your IDE Debug window. It will print the entire string:
Code:
    TRACE("%s\n", sz_sqlString);
[\code]

Shyan
 
Shyan,

Thanks for the info. [2thumbsup] I'll be using "TRACE..." in the future!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top