Thursday 15 April 2010

c# - OleDbCommand with bind variables -



c# - OleDbCommand with bind variables -

i trying utilize bind variables oledbcommand. have next code

var sql = @"select * table order_no = '@order_no'"; using (var cmd = new oledbcommand(sql, connection)) { cmd.parameters.add(new oledbparameter("@order_no", "1234")); using (var dr = cmd.executereader()) { while (dr.read()) { // } } }

when run code nil returned database. if alter sql be

var sql = @"select * table order_no = '1234'";

a result returned. doing wrong?

remove apostrophes around @order_no:

var sql = @"select * table order_no = @order_no";

otherwise it's not parameter string literal , you're looking order_no = @order_no.

c# database oracle oledbcommand

No comments:

Post a Comment