Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm getting this error while inserting data from my form to database using LinQ

When I enter the object of the class(e.g: Employee empObj = new Employee()) It shows the error.
using (DataClass1DataContext DcContext = new DataClass1DataContext())
                {
                    ArticleMdl articleObj = new ArticleMdl();
                    articleObj.Title = TextBox1.Text;
                    articleObj.Summary = TextBox2.Text;
                    articleObj.Tags = TextBox3.Text;
                    articleObj.Image = TextBox4.Text;
                    articleObj.Category = Convert.ToInt32(RadioButtonList1.SelectedValue);
                    articleObj.Subcategory = Convert.ToInt32(RadioButtonList2.SelectedValue);
                    
                    DcContext.tblArticles.InsertOnSubmit(articleObj);
                    DcContext.SubmitChanges();
                    Label1.Text = "Your article is saved.";
                }


Error 1 The best overloaded method match for 'System.Data.Linq.Table.InsertOnSubmit(Linqtosql1.tblArticle)' has some invalid arguments

Please do reply how to recover it.

What I have tried:

Tried to insert on putting of direct values to the properties. The same error arose.
Posted
Updated 3-Jan-17 4:58am
v3
Comments
Suvendu Shekhar Giri 3-Jan-17 4:40am    
From the error it looks like you are passing the wrong object for insert.
[no name] 3-Jan-17 8:24am    
Use valid arguments for method calls and your problem will be solved.
Philippe Mori 3-Jan-17 9:24am    
Where is your code? It is hard to help you if we cannot see what you do. Post relevant code with your question.
cgprakash 3-Jan-17 10:54am    
using (DataClass1DataContext DcContext = new DataClass1DataContext())
{
ArticleMdl articleObj = new ArticleMdl();
articleObj.Title = TextBox1.Text;
articleObj.Summary = TextBox2.Text;
articleObj.Tags = TextBox3.Text;
articleObj.Image = TextBox4.Text;
articleObj.Category = Convert.ToInt32(RadioButtonList1.SelectedValue);
articleObj.Subcategory = Convert.ToInt32(RadioButtonList2.SelectedValue);
DcContext.tblArticles.InsertOnSubmit(articleObj);
DcContext.SubmitChanges();
Label1.Text = "Your article is saved.";
}

1 solution

The object you're passing to the method is not of or derived from type TEntity.
 
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