Forum Discussion

mvlaicov's avatar
mvlaicov
Occasional Contributor
8 years ago
Solved

How to use Update and delete SQL statements using ADO

I am attempting to "Clean" mySQL database before I start my functional test. I am hung up on executing insert and delete SQL statements on the database. I am able to connect and run queries through the ado calls but I  cannot figure out how to run insert or delete statements. Can someone post a possible example for me?

8 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Could you post the code that you are using for the queries you can run? As far as i know, it SHOULD be very similar code.

    • mvlaicov's avatar
      mvlaicov
      Occasional Contributor
      procedure CleanDB;
      var
        AConnection : OleVariant;
        SQLQry : string;
      begin
        //Create new connection object
        AConnection := ADO.CreateADOQuery;
        
        //Run Scripts
        SQLQry := 'SELECT * from Provinces;';
        
        //specify the connection string
        AConnection.connectionstring := HIDDEN;
        
        //disable prompt for login
        //AConnection.LoginPrompt := false;
       
        
        AConnection.SQL := SQLQry; 
        AConnection.Open;  
        
        AConnection.Close;
      end;

      We are running a simple select statement in here that works. But I want to be able to run a series of inserts or possibly delete statements on the database.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        What happens when you replace

         

        SQLQry := 'SELECT * from Provinces;';

         with 

         

        SQLQry := 'DELETE * from Provinces;';

        It SHOULD be pretty straight forward...  Are there error messages that come up?