private void WStoreSystem_Load(object sender, EventArgs e) { ////////////////////////////////////////////////////////////////////// string str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\WStoreSystem\\WStoreSystem\\WStoreSystem\\bin\\Debug\\StoreSys.mdb"; OleDbConnection con = new OleDbConnection(str); var dss = new DataSet(); var adapter = new OleDbDataAdapter("SELECT ProName FROM Products", con); con.Open(); adapter.Fill(dss); DataTable dt; dt = dss.Tables[0]; Dictionary<string, string> ProName = new Dictionary<string, string>(); the error is : Column 'ProductID' does not belong to table Table. foreach (DataRow row in dss.Tables[0].Rows) { ProName.Add(row["ProductID"].ToString(), row["ProName"].ToString()); //Product name is the key. } listBox1.DataSource = ProName; listBox1.DisplayMember = "Key"; listBox1.ValueMember = "Key"; con.Close(); ///////////////////////////////////////////////////////////////////// ProductsClass prod = new ProductsClass(); DataSet ds = prod.get(); DGV1.DataSource = ds.Tables[0]; DGV1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; DGV1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.ControlBox = false;
ProName
ProductID
SELECT
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)