Click here to Skip to main content
16,020,289 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
private void AddProductsToTabbedPanel()
        {
            int i = 1;

            foreach (TabPage tp in tabControl1.TabPages)
            {
                ObjectQuery<tblproduct> filteredProduct = new ObjectQuery<tblproduct>("SELECT VALUE P FROM tblProduct AS P WHERE P.ProductType=" + i.ToString(),pce);

                FlowLayoutPanel flp = new FlowLayoutPanel
                {
                    Dock = DockStyle.Fill
                };

                foreach (tblProduct tprod in filteredProduct)
                {
                    Button b = new Button
                    {
                        Size = new Size(100, 100),
                        Text = tprod.Description,
                        Tag = tprod
                    };
                    b.Click += new EventHandler(UpdateProductList);

                    tp.Controls.Add(b);
                    flp.Controls.Add(b);
                }

and here
C#
private void FilterList(object sender, EventArgs e)
        {
            ObjectQuery<tblproduct> filteredProducts = new ObjectQuery<tblproduct>("SELECT VALUE product FROM tblProducts AS product WHERE product.ProductType = " + cboFilter.SelectedValue,pce);
            dataGridView1.DataSource = filteredProducts;
        }


What I have tried:

tried to update EF model to latest version but that dosent fix the problem
Posted
Updated 9-Oct-17 1:08am
v3
Comments
Quirkafleeg 20-Sep-17 12:22pm    
Your problem is "pce", which should be of type "ObjectContext" - and it is not. Given you have not provided any code regarding what "pce" is, I cannot provide anything more.

1 solution

you must use a correct object of your type. Is it a typo or some bigger issue, that pce isnt of the right type.

But for sure you next a proper object context, so correct your code to provide a valid context for the query. Take care of the possible SQL injections!!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900