passing parameter to access query from c# -
i have design access query seem this:
select replace(names,'lion','kiss') expr1 table1;
the 2 values lion , kiss, temporary, want these 2 variables, can pass value c#.
how call query c#, , pass 2 values.
i using access 2007.
thanks :)
try (i found this on subject):
public void replacecolumna(string oldvalue, string newvalue) { using(oledbconnection connection1 = (oledbconnection)databaseconnection.instance.getconnection()) { connection1.open(); using(oledbcommand sqlcmd2 = new oledbcommand("queryname", connection1)) { sqlcmd2.parameters.addwithvalue("param1", newvalue); sqlcmd2.parameters.addwithvalue("param2", oldvalue); sqlcmd2.executenonquery(); } } }
the access query this:
update [t] set [a] = ? [a] = ?
the names of parameters pass on don't matter, it's order pass them as.
by using "using" statement ensure .net releasing connections , resources.
additionally recommend switching sql server express edition. it's free , lot more potent can cook in access. really, you're shooting in foot continuing in access...
Comments
Post a Comment