🎉 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

Started by
4 comments, last by Benjamin 23 years, 10 months ago
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
Ben
Advertisement
LPCTSTR szSQL = "SELECT * FROM /*some table name here*/ WHERE USERNAME =" & sss;
For C/C++:

    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
p
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);
Ben
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.



Btw, I would use LIKE instead of =, even tho that works

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
---Irek | irek@seventh.net
I made a stupid mistake, I accidently disconnect the database.

Now that''s alright. thanks
Ben

This topic is closed to new replies.

Advertisement