sql server - Get int type from Database c# -


i'm trying retrieve piece of data of type int database.

here code:

using (sqldatareader dr = query.executereader()) {     bool success = dr.read();      if (success)     {         label7.text = dr.getint32(0);     } }  con.close(); 

this throws error:

cannot convert type 'int' 'string'.

any idea how fix code?

you're trying assign number property accepts strings... error warning about.

convert number string before assigning label.

label7.text = convert.tostring(dr.getint32(0)); 

Comments