c# - How do I use the value of a cell when I know the id of a row? -


i have int value h, , want search in database (column id) h value. when row, want particular cell represents price, , want use later in code. if player has money , wants buy thing h id, value of thing subtracted sum of money.

so how price , use it? know did here isn't good.

void titlucasuta(int h) {   deschideconexiunea();   string s = "select titlu titluriproprietate id=h";   cmd = new sqlcecommand(s, con);   cmd.executenonquery(); } 

you hard-coded "h" query. it's not using value @ all. read on using parameters.

string query = "select titlu titluriproprietate id = @id";  using (var cmd = new sqlcecommand(query, con)) {     cmd.parameters.add(new sqlceparameter("@id", sqldbtype.int, h));      return convert.todecimal(cmd.executescalar()); } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -