Forum Discussion

mrezahoseini's avatar
mrezahoseini
Contributor
10 years ago

Execute Several Queries at once in one connection

I would like to Execute serveral queries at once and don't know how to do it

 

my code is like this:

 

 

var AConnection, Driver;


AConnection = ADO.CreateADOConnection();


AConnection.ConnectionString = "Provider=MSDAORA.1;Password=xHl4C06T;User ID=chapar941_Auto;Data Source=srv28;Persist Security Info=True";


AConnection.LoginPrompt = false;


AConnection.Open();


var Driver = DDT.ExcelDriver("C:\\Add-EventTypes.xls", "Sheet1");


var k = aqConvert.VarToStr(Driver.Value(0));


var str = "delete from template where template.et_id in(select id from eventtype where name like '"+k+"');delete from predefined_template where predefined_template.et_id in(select id from eventtype where name like '"+k+"');delete from eventtype where name like '"+k+"'";


// AConnection.Execute(str,1,128);

 

Spoiler
AConnection.Execute_(str); // in this line I bumped into a prblem like attachment

 


DDT.CloseDriver(Driver.Name);


AConnection.Close();

 

 

 

 

 

 

 

  • I solved it we can use "AConnection.Execute_(str);" after each query

     

    we should not concat queries and convert them into one string

     

    we should execute each query lonely

     

     

  • I solved it we can use "AConnection.Execute_(str);" after each query

     

    we should not concat queries and convert them into one string

     

    we should execute each query lonely

     

     

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      Hi,

       

      Yes, your finding was correct - ADO, which is a background data provider for both ADO and DDT objects does not support batch executions and is limited to one SQL instruction per command.