06-10-2010 01:16 PM
Hello
I am trying the following query.
hstmt = DBActivateSQL(hdbc, "SELECT UserLevel FROM ClassUsers WHERE Password = "+ cadena +"");
At this point I recieve this error:
Operands of + have illegal types 'pointer to char' and 'pointer to char'.
I have tried this:
hstmt = DBActivateSQL(hdbc, "SELECT UserLevel FROM ClassUsers WHERE Password = "+ &cadena +"");
hstmt = DBActivateSQL(hdbc, "SELECT UserLevel FROM ClassUsers WHERE Password = '"+ cadena +"'");
Still having the same problem.
It works fine if I do this.
hstmt = DBActivateSQL(hdbc, "SELECT UserLevel FROM UserClass WHERE Password = 'cadena'");
Where 'cadena' is treated as a string.
Any Ideas?
Thanks!
Solved! Go to Solution.
06-11-2010 03:23 AM
The Visual Basic method of concatenating strings with the + operator doesn't work in C. You can use a number of ways to do this - here is just a sample:
char string [256] = "SELECT UserLevel FROM ClassUsers WHERE Password = ";
hstmt = DBActivateSQL(hdbc, strcat (string, cadena));
JR
06-12-2010 11:23 AM
Nice One JR.
I was using not the VB but the C# .NET method, which I assume is the same as VB way.
Yours is the pretty rigth solution, just missig the adding of "'" (apostrophe character) to diferentiate between chars and numbers at any further query which was solved by the using of strcat() again.
Thanks for this.
Victor