c# - How to wait for a database command to complete one iteration before continuing in foreach loop -


i know how wait database command complete before going next iteration in each loop.

the following code send sql statement "exec ups_storedproc" without waiting next 1 complete:

foreach (var guid in anuseridlist)             {                 database.executecmd(string.format("exec dbo.usp_storedproc @membercontactid = '{0}'", guid), con);             } 

i've tried result of stored proc in variable returns 0 though command did not complete yet.

int result =  database.executecmd(string.format("exec dbo.usp_storedproc @membercontactid = '{0}'", guid), con); 

thank you

you'd have check on documentation call.

from comment, see method signature is:

public static int executecmd(string sqlcommand, idbconnection con, params dbparam[] params); 

from experience, hazard guess already blocking call, , returns number of affected rows. if that's case, you've got should work.

what makes think stored procedure should returning other 0? sure that's working?

if, you've suggested, non-blocking call, there's nothing can do. unless returned integer refers joinable task, it's "lost." awful design decision, though, doubt it.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -