sqlcommand.execution - multiple result (2-insert and 1-Select)?  
Author Message
CoolTami





PostPosted: .NET Framework Data Access and Storage, sqlcommand.execution - multiple result (2-insert and 1-Select)? Top

Hi,

I have sql statment something like this

string sql = "Insert into table1 values('abc',100);Select * from table1;Insert into table1 values('xyz',200);";

when I execute this sql in sqlcommand using  ExecuteNonQuery, the result is 2 (Total Insert)

When I execute this sql in SqlAdapter using fill, the result is dataset is filled by select * from table1.

But I would like to have one execution which will return 2(number of insert (in order of insert exeuction) and dataset for select statement.

What I understand from the execution is that It executes all sql which is there in commandtext, but it returns based on your exeuction method.

So is there anyway I can get all result in one exeuction

Thanks.

 




.NET Development5  
 
 
Luis D. Rojas





PostPosted: .NET Framework Data Access and Storage, sqlcommand.execution - multiple result (2-insert and 1-Select)? Top

Hi RaviR,

I think you should think on moving this 2 steps to a store procedure. So you will have the chance to do the insert and then do the select.

You can not fill a DataSet using using the ExcecuteNonQuery Method, so That is why I think that moving this functionality to a store procedure will be better; besides, you will have more advantages like perfomance improvement.

Best Regards