Home > Software engineering >  MFC '=' near a syntax error, unable to predefined statements
MFC '=' near a syntax error, unable to predefined statements

Time:10-07

Void CDishSearch: : OnSearch ()
{
Extern CDatabase m_database;
Extern CShowDish * DishShowDlg;
CDishSet m_dish;
M_dish. M_pDatabase=& amp; M_database;
Cstrings SQL;
The UpdateData (TRUE);
SQL. The Format (" select * from log table ");
If (m_namectrl GetCheck ())
{
If (m_name==_T (" "))
{
MessageBox (" please enter the food name ");
return;
}
SQL=SQL + "where package name='" + m_name +"' ";
}
The else
{
SQL + SQL="where user ID='" + username +"' ";
}
M_dish. Open (AFX_DB_USE_DEFAULT_TYPE, SQL);
DishShowDlg - & gt; ShowWindow (SW_SHOW);
//DishShowDlg - & gt; OnRefreshData ();
ShowWindow (SW_HIDE);
}
Why in the SQL statement will have a problem, just self-study MFC small white for help, set was a lesson to the due dates

CodePudding user response:

SQL out look at the syntax format problem printing

CodePudding user response:

SQL=SQL + "where package name='" + m_name +"' ";

If it is as you say, here the grammar correctly.

Estimated that your SQL or m_name not cstrings type.
Here have to use the Format to Format, do not use the +

If it is a SQL query, database syntax errors, then basically is the text string has a problem, the database basically won't do the field name in Chinese

CodePudding user response:

SQL. The Format (" select * from log table ");
Instead of
SQL. The Format (" select * from log table ");
  • Related