Advertisement

Get File by SQL statemen

Started by August 07, 2000 05:53 AM
1 comment, last by Benjamin 24 years, 4 months ago
I have the following code to check a player''s account and find the relevant data LPCTSTR szSQL = "SELECT * FROM .... 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
quote: Original post by Benjamin

I have the following code to check a player''s account and find the relevant data

LPCTSTR szSQL = "SELECT * FROM .... 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


Hi,

i think the problem is the construction of the SQL string and the ''sss''. I suggest you must hash the '' (apostrophes) somehow. For details look into your docu.

Maybe it is something like:

String UserName = "''''sss'''';

or

String UserName = "\''sss\'';

I think you must simply test that out.

cu

Peter
HPH
Advertisement
Check out the following links:
http://msdn.microsoft.com/library/psdk/dasdk/odch8bjn.htm
http://msdn.microsoft.com/library/psdk/dasdk/odch3k4u.htm

There are examples for binding variables and preparing a SQL statement.

Check out also the ODBC doc:
http://msdn.microsoft.com/library/psdk/dasdk/odbc4vcn.htm

Cant you use embedded SQL using a precompiler instead of the ODBC API? It would be way easier...

Have fun,
Semiel.

This topic is closed to new replies.

Advertisement