Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL - DELETE Directive error

SQL - DELETE Directive error

Scheduled Pinned Locked Moved Database
databasehelpc++question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • L Lost User

      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

      L Offline
      L Offline
      Looney Tunezez
      wrote on last edited by
      #2

      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

      L A 2 Replies Last reply
      0
      • L Looney Tunezez

        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

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        thanks man it worked :)


        "Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill

        1 Reply Last reply
        0
        • L Looney Tunezez

          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

          A Offline
          A Offline
          Andre Ziegler
          wrote on last edited by
          #4

          Looney Tunezez wrote:

          Application.Run(new Form1(this.Dispose()));

          *ROFL* Where do you get this code? :laugh:

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups