ms access - C# - Using OleDbParameter on table name -



ms access - C# - Using OleDbParameter on table name -

i want protect app sql injection. want utilize oledbparameter in sql query table name ({1}).

the problem doesn't work (error in or that). can pass oledbparameter in {3} thought. example:

idbcommand cmd = m_oconnection.createcommand(); cmd.commandtype = commandtype.text; cmd.commandtext = string.format("select {0} {1} {2}={3}", "parentid", "?", swhere, "?" ); cmd.parameters.add(new oledbparameter("@stable", stable)); cmd.parameters.add(new oledbparameter("@id", id));

what can do? forced write function escapes sql characters hand? if yes, can find perfect function?

thanks

so know can't parameterize table names this

cmd.commandtext = string.format("select {0} [{1}] {2}={3}", "parentid", stable, swhere, "?"

but unsafe if , if stable comes user input. if straight command stable don't have worry it.

if indeed come user input you'll need protect yourself. easiest way create sure stable valid table, attached table, or query name

to execute

select name myssobjects type in (1,5,6,)

to list of valid values stable.

depending on application execute 1 time , cache results don't have every time phone call method.

c# ms-access sql-injection

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -