can anyone tell me ? why i am getting the following error .when i tried to complile.
Error 1 foreach statement cannot operate on variables of type 'Brands.BrandCol' because 'Brands.BrandCol' does not contain a public definition for
'GetEnumerator' F:\C#Progress\RPM\Brands\Brands\Form1.cs 52 13 Brands
Code:namespace Brands { public partial class Form1 : Form { private BrandCol mcol = new BrandCol(); // private Dictionary<BrandCol mcol>(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { string strsql = null; string strConn = Properties.Settings.Default.Path + "\\" + Properties.Settings.Default.DatabaseName; using (OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strConn)) { conn.Open(); strsql = "Select * from Brand"; OleDbCommand cmd = new OleDbCommand(strsql, conn); cmd.CommandText = strsql; OleDbDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { BrandCls Brand = new BrandCls(); Brand.Brandid = reader.GetByte(0); Brand.BrandName = reader.GetString(1); mcol.AddBrand(Brand); } } } } public void FillListBox() { foreach (BrandCls brand in mcol) listBox1.Items.Add(brand.BrandName); } } }




Reply With Quote