c# - Binding SQL data to Label in WPF -


is there way data bind sql data label in wpf?

i have sql database has total of summed data. want display last column's data label. if column reads "10" need label display "10".

here code i've tried:

c#:

sqlconnection con = new sqlconnection(myconnectioninfo); sqlcommand scom = new sqlcommand(); scom.commandtext = "select top 1 [totalincidents] sixmonthreport order [totalincidents] desc" object temp = cmd.executescalar(); label.text = temp.tostring(); 

most appeared work until label.text portion not option in wpf.

i can't seem find information on of wpf / labels appreciated.

label not have text property have content one, can try like:

object temp = null; using (sqlconnection con = new sqlconnection(myconnectioninfo)) {     con.open();     using (sqlcommand command = new sqlcommand("select top 1 [totalincidents] sixmonthreport order [totalincidents] desc", con))     {         temp = cmd.executescalar();     } } label.content = temp?.tostring(); 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -