Once you have them working, you should have a sufficient degree of understanding to attack your own related LINQ problems.
Note that syntactically, LINQ to SQL and LINQ to Entities are sufficiently similar to each other so as to not pose much of a challenge to you.
Regards,
Gerry (Lowry)
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
Marked as answer by ricka6 on Feb 16, 2010 04:26 PM
IF you can use EF (the future direction of MS), My sample is better, more complete and doesn't waste time creating a DB (90% of the other tutuorials - and that has nothing to do with MVC).
aapka.seeman...
0 Points
14 Posts
How to Insert data into database
Feb 16, 2010 11:35 AM|LINK
Hi
I am new in ASP.Net MVC and facing problam to insert data into database.I am using LINQ to SQL(test.dbml) and Model1.edmx
My controller code is bellow
Function Index() As ActionResult
Dim db = New dbTestEntities() ' dbTest is my database
Dim testtable = New dbtestTable()
Dim mytest = New testDataContext()
testtable.Customer_ID = 3
testtable.Company = ""
testtable.First_Name = ""
testtable.Last_Name = ""
db.AddToTestTable(testtable) 'TestTable is my database table
db.SaveChanges()
Return View(testadd)
End Function
This code show ERROR Invalid column name
Is this Code is correct ?, IF any other solution is avalable plese tell me.
ASP.NET MVC "ASP.NET MVC" HtmlHelper ActionLink "Unit Tests" "asp.net mvc rc" "ASP.NET MVC 1.0" "ASP.NET MVC v1.0" "LINQ to SQL" "MVC 1.1" MVC Blinq Linq to SQL "MVC" asp.net to MVC "ASP.NET MVC"
gerrylowry
All-Star
20525 Points
5713 Posts
Re: How to Insert data into database
Feb 16, 2010 01:19 PM|LINK
See and actually DO the movie database tutorials:
Create a Movie Database Application in 15 Minutes with ASP.NET MVCView in VB or C#
The above uses LINQ to Entities.
Creating Model Classes with the Entity FrameworkView in VB or C#
and
Creating Model Classes with LINQ to SQLView in VB or C#
Once you have them working, you should have a sufficient degree of understanding to attack your own related LINQ problems.
Note that syntactically, LINQ to SQL and LINQ to Entities are sufficiently similar to each other so as to not pose much of a challenge to you.
Regards,
Gerry (Lowry)
ricka6
All-Star
15070 Points
2272 Posts
Microsoft
Moderator
Re: How to Insert data into database
Feb 16, 2010 04:29 PM|LINK
IF you can use EF (the future direction of MS), My sample is better, more complete and doesn't waste time creating a DB (90% of the other tutuorials - and that has nothing to do with MVC).
How to: Validate Model Data Using DataAnnotations Attributes
Walkthrough: Using Templated Helpers to Display Data