SQL - DELETE Directive error
-
Hello guys, I have a MFC dialog based application which Is loading some data from a *.mdb database file , but I have problems when I want to delete a record there . Suppose we have next situtation. Table1 in my database file looks like this :
ID Name Surname 1 nick Gates 2 john Allen 3 david Ellison
And I want to delete the secont record :2 john Allen
So I am doing following :void CMyDlg::OnDelete()
{
...
TRY
{
database.Open(NULL,false,false,sDsn);
CRecordset recset( &database );//Here I get error SqlString.Format("DELETE from Table1 WHERE Name IS '%s'",sParam); database.ExecuteSQL(SqlString); }
CATCH(CDBException, e)
{
AfxMessageBox("Database error: "+e->m_strError);
}
END_CATCH;...
}I get error Message Box : "Invalid use of IS Operator in expression 'Name IS john''" Can anyone help what's wrong with the IS directive above??
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
-- modified at 9:41 Friday 21st October, 2005 -
Hello guys, I have a MFC dialog based application which Is loading some data from a *.mdb database file , but I have problems when I want to delete a record there . Suppose we have next situtation. Table1 in my database file looks like this :
ID Name Surname 1 nick Gates 2 john Allen 3 david Ellison
And I want to delete the secont record :2 john Allen
So I am doing following :void CMyDlg::OnDelete()
{
...
TRY
{
database.Open(NULL,false,false,sDsn);
CRecordset recset( &database );//Here I get error SqlString.Format("DELETE from Table1 WHERE Name IS '%s'",sParam); database.ExecuteSQL(SqlString); }
CATCH(CDBException, e)
{
AfxMessageBox("Database error: "+e->m_strError);
}
END_CATCH;...
}I get error Message Box : "Invalid use of IS Operator in expression 'Name IS john''" Can anyone help what's wrong with the IS directive above??
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
-- modified at 9:41 Friday 21st October, 2005Try LIKE instead of IS. for eg DELETE from Table1 WHERE Name LIKE '%s' Cheers! Looney Tunezez "If you build it.... .....BUGS will come!" -JB
Application.Run(new Form1(this.Dispose())); <--WHAT :wtf::confused::eek:
"Stability. What an interesting concept" - Chris Maunder -
Try LIKE instead of IS. for eg DELETE from Table1 WHERE Name LIKE '%s' Cheers! Looney Tunezez "If you build it.... .....BUGS will come!" -JB
Application.Run(new Form1(this.Dispose())); <--WHAT :wtf::confused::eek:
"Stability. What an interesting concept" - Chris Maunder -
Try LIKE instead of IS. for eg DELETE from Table1 WHERE Name LIKE '%s' Cheers! Looney Tunezez "If you build it.... .....BUGS will come!" -JB
Application.Run(new Form1(this.Dispose())); <--WHAT :wtf::confused::eek:
"Stability. What an interesting concept" - Chris MaunderLooney Tunezez wrote:
Application.Run(new Form1(this.Dispose()));
*ROFL* Where do you get this code? :laugh: