Hi again, I'm having trouble whilst connecting a MS access db using oleDB
Problem is with getting more than one column added into a listbox in my application from the DB
here's the code so far
OleDbConnection Conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Scott\\Documents\\Menu.accdb");
OleDbDataAdapter da = new OleDbDataAdapter(
"Select * from Menu", Conn);
DataSet ds = new DataSet();
da.Fill(ds);
DataTable dt = ds.Tables[0];
foreach (DataRow dr in dt.Rows)
{
listBox1.Items.Add(dr["Dish"]);
}
}
I just can't find a way to get the second column added ?
thanks,Scott
Connect Ms access DB oleDb problem
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Jan MontanoRank #1,295 · 1.3K reputationPosted Jan 12, 2009, 10:02 PM EST
try
listBox1.Items.Add((string)dr["Dish"] + " - " + (string)dr["Food"]);
or
listBox1.Items.Add((string)dr["Dish"] + " - " + (string)dr[1]);
Guest UserRank #1,422 · 1.2K reputationPosted Jan 13, 2009, 12:44 PM EST