Re: SQL statement with MFC
What do you mean "attach 2 variables"?
Re: SQL statement with MFC
Code:
CString X("2");
CString SQL1;
SQL1= "SELECT Col1 from Table where Col2="+X;
This doesn't compile for me (after correcting the typo)
Try this (for two variables)
Code:
CString X("2");
CString Y("3");
CString SQL1;
SQL1 = CString("SELECT Col1 from Table where Col2=") + X + Y;
Re: SQL statement with MFC
Quote:
Originally Posted by
JohnW@Wessex
Code:
CString X("2");
CString SQL1;
SQL1= "SELECT Col1 from Table where Col2="+X;
This doesn't compile for me (after correcting the typo)
Try this (for two variables)
Code:
CString X("2");
CString Y("3");
CString SQL1;
SQL1 = CString("SELECT Col1 from Table where Col2=") + X + Y;
That would give him Col2 = 23. I don't think that's what he means.
Re: SQL statement with MFC
Thanks for all,
But I mean I want to attach 2 variables to match them with two column's values like:
CString SQL = " SELECT Col1 from Table where Col2= Variable1 and Col2= Variable2 "
My tries were:
CString SQL = " SELECT Col1 from Table where Col2="+X AND Col3="+Y "; // failed
CString SQL = " SELECT Col1 from Table where Col2=+X AND Col3=+Y "; // failed
CString SQL = " SELECT Col1 from Table where Col2='+X' "AND" Col3='+Y' "; // failed
CString SQL = " SELECT Col1 from Table where Col2= AND Col3="+X +Y "; // failed
CString SQL = " SELECT Col1 from Table where Col2=' "+X+" ' AND Col3=' "+Y+ " ' "; // failed
I think my problem with the syntax code not anything else.
Any help please
Re: SQL statement with MFC
Quote:
Originally Posted by
hijjawi
Thanks for all,
But I mean I want to attach 2 variables to match them with two column's values like:
CString SQL = " SELECT Col1 from Table where Col2= Variable1 and Col2= Variable2 "
My tries were:
CString SQL = " SELECT Col1 from Table where Col2="+X AND Col3="+Y "; // failed
CString SQL = " SELECT Col1 from Table where Col2=+X AND Col3=+Y "; // failed
CString SQL = " SELECT Col1 from Table where Col2='+X' "AND" Col3='+Y' "; // failed
CString SQL = " SELECT Col1 from Table where Col2= AND Col3="+X +Y "; // failed
CString SQL = " SELECT Col1 from Table where Col2=' "+X+" ' AND Col3=' "+Y+ " ' "; // failed
I think my problem with the syntax code not anything else.
Any help please
CString SQL;
SQL.Format("SELECT Col1 from table where Col2 = %d AND Col3 = %d", x, y);
Re: SQL statement with MFC
Dear GCDEF,
Thank you very much its work now .
thanks alot and best regards