Home > Software engineering >  The executesql invalid SQL statements
The executesql invalid SQL statements

Time:10-11

Want to have a login registration screen, connect the access, login, is registered there is a problem, want to make a great god, look at what is going wrong?
The UpdateData (TRUE);//update data
CDatabase db.
The db. The Open (_T (" mydb "));
Cstrings sname;
_variant_t varname;
CRecordset dbset (& amp; Db);
Dbset. Open (CRecordset: : dynaset, _T (" select * from the user "), 0).
Sname=(LPCSTR) _bstr_t (varname);
If (m_regname. IsEmpty () | | m_regpsd. IsEmpty ())
{
MessageBox (L "information can't be empty!" );
}
The else
{
If (sname.Com pare said (m_regname)!=0)//if the name in the input box in the database, there is no
{
Try
{
The db. The ExecuteSQL (_T (" uname=m_regname ") _T (" upassword=m_regpsd ") _T (" utype='1' "));
}
The catch (CDBException * PE)
{
PE - & gt; ReportError ();
PE - & gt; The Delete ();
}
}
The else
{
MessageBox (L "this user already exists!" );
}
}
Dbset. Close ();

CodePudding user response:

SQL statement error, string types should be wrapped up in single quotation marks, and string spelt wrong, it is best to use cstrings Format to spell would have been better,

CodePudding user response:

The db. The ExecuteSQL (_T (" uname=m_regname ") _T (" upassword=m_regpsd ") _T (" utype='1' "));
I'm not so, I have just finished an SQL statement, if you want to insert a record, should be to use the insert
  • Related