I copied your code and added comments:
public partial class StockIn : Form
{
private DataSet DtposMenuDS = new DataSet("DtposMenu");
private DataTable starterTable = null;
public StockIn()
{
InitializeComponent();
}
private void cmdExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void cmdStarters_Click(object sender, EventArgs e)
{
OleDbConnectionStringBuilder connBuilder = new OleDbConnectionStringBuilder();
connBuilder.DataSource = @"C:\Users\AP_AE\Desktop\DTPOS_APP\DataBase\DtposMenu.accdb";
connBuilder.Provider = "Microsoft.ACE.OLEDB.12.0";
connBuilder.Add("Jet OLEDB:Engine Type", "5");
string foodTypeSql = @"SELECT FoodName, FoodType FROM Food WHERE FoodType = @foodType";
using (OleDbConnection conn = new OleDbConnection(connBuilder.ConnectionString))
{
try
{
conn.Open();
OleDbCommand foodsCommand = new OleDbCommand(foodTypeSql, conn);
OleDbParameter foodType = foodsCommand.Parameters.Add("@foodType", OleDbType.VarChar, 15);
OleDbDataAdapter foodsDa = new OleDbDataAdapter(foodsCommand);
foodType.Value = "Starter";
foodsDa.Fill(DtposMenuDS, "Food");
starterTable = DtposMenuDS.Tables["Food"];
ListViewItem foodItem = new ListViewItem();
foodItem.SubItems.Add(((DataRowView)DtposMenuBS.Current)["FoodName"].ToString());
this.listViewItemsInStock.Items.Add(foodItem);
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex);
}
}
}
}
Hope that helps!
Cheers,
Manfred