c# - executing SqlCommand statement and displaying result in a label -
i executing stored procedure , want change instead of returning of results , handling them. want return , display information in third column stored procedure label.text on winforms app. how can go doing that.
public ienumerable getguids(int id) { using (sqlcommand _command = new sqlcommand("storedproc")) { _command.connection = new sqlconnection(constring); _command.connection.open(); _command.commandtype = commandtype.storedprocedure; _command.parameters.addwithvalue("@itemid", id); return _command.executereader(); } }
i want display items returned in 3rd column stored procedure follows: itemrow1/itemrow2.
public ienumerable getguids(int id) { list<string> items = new list<string>(); using (sqlcommand _command = new sqlcommand("storedproc")) { _command.connection = new sqlconnection(constring); _command.connection.open(); _command.commandtype = commandtype.storedprocedure; _command.parameters.addwithvalue("@itemid", id); using (var reader = _command.executereader()) { while (reader.read()) { items.add(reader[2].tostring()); } } } return items; }
should you. wherever label is, like
label.text = string.join(",", items.toarray());
or want display it
Comments
Post a Comment