c# - is Microsoft.Practices.EnterpriseLibrary.Data.Database.SetParameterValue thread safe? -


i'm using database run queries , thinking optimize stuff up.

i doing 2 static objects:

private static database db = ... ; private static dbcommand cmd = db.getsqlstringcommand("... col = @colparam"); .... cmd.prepare(); //one call 

and thinking do:

db.addinparameter(cmd, "colparam", dbtype.string, "some value on each call") 

when calling it.

it works 1 time. after first call receive

variable names must unique within query batch or stored procedure

an error message regarding @colparam parameter.

so thinking in replacing add set @ each call:

db.setparametervalue(cmd, "colparam", "some value on each call") 

but safe? have feeling...??!?!?!?.

is thread safe have 1 command object on set value on each call? if 2 users set value @ same time? happens then?

this in premature optimisation bucket. not sure think optomising.

your real questions should dbcommand thread safe. answer no. documenation on dbcommand http://msdn.microsoft.com/en-us/library/system.data.common.dbcommand.aspx.

any instance members not guaranteed thread safe.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -