🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
SQL statement problem
I have the following code to check a player''s account and find the relevant data
LPCTSTR szSQL = "SELECT * FROM /*some table name here*/ WHERE USERNAME = ''sss''";
if (SQL_SUCCESS == ( rc = ::SQLPrepare(hstmt,(unsigned char *)szSQL,SQL_NTS)))
{
if (SQL_SUCCESS == (rc = ::SQLExecute(hstmt)))
//do something
if I just type the exact name this code run no problem, when I want to change the name to a string variable. this
code just not reponse
What''s problem
For C/C++:
Pax
LPCTSTR szSQL;sprintf(szSQL, "SELECT * FROM /*some table name here*/ WHERE USERNAME = ''%s''", name);if (SQL_SUCCESS == ( rc = ::SQLPrepare(hstmt,(unsigned char *)szSQL,SQL_NTS))){if (SQL_SUCCESS == (rc = ::SQLExecute(hstmt)))//do something
Pax
I try to use sprintf, but still not work, my code is:
sprintf((char *)szSQL,"SELECT Profile.Login_ID, Profile.Point FROM Profile WHERE Login_ID = ''%s''",LogID);
sprintf((char *)szSQL,"SELECT Profile.Login_ID, Profile.Point FROM Profile WHERE Login_ID = ''%s''",LogID);
Now its time to do standard debugging..
Print the LogID to screen..
Then after the sprintf, print the szSQL string..
That way you can see exactly what its doing.
![](smile.gif)
Btw, I would use LIKE instead of =, even tho that works![](smile.gif)
Pax - How do you do the little syntax color coded box for code snippets?
---
Irek | irek@seventh.net
Edited by - Irek on August 10, 2000 2:07:14 AM
Print the LogID to screen..
Then after the sprintf, print the szSQL string..
That way you can see exactly what its doing.
![](smile.gif)
Btw, I would use LIKE instead of =, even tho that works
![](smile.gif)
Pax - How do you do the little syntax color coded box for code snippets?
---
Irek | irek@seventh.net
Edited by - Irek on August 10, 2000 2:07:14 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement