public class CAt : ICat { int _categoryid; string _categoryname; string _description; byte _image; public int categoryid { get { return _categoryid; } set { _categoryid = value; } } public string categoryname { get { return _categoryname; } set { _categoryname = value; } } public string description { get { return _description; } set { _description = value; } } public byte image { get { return _image; } set { _image = value; } } } }
public List<cat> GetCategories() { List<cat> lst = new List<cat>(); cn = new SqlConnection(con); string query = "Select Categoryid, categoryname, description, picture from Categories"; cmd = new SqlCommand(query, cn); cn.Open(); dr = cmd.ExecuteReader(); try { while (dr.Read()) { CAt c = new CAt(); c.categoryid = (int)dr["categoryid"]; c.categoryname = dr["categoryname"].ToString(); c.description = dr["description"].ToString(); c.image = Convert.ToByte(dr["picture"]); lst.Add(c); } return lst; } catch (Exception ex) { throw ex; } finally { cn.Close(); } }
throw
CAt.image
IConvertible
byte[]
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)