Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi i want insert a new record by language lambda in web form my data base is sql server 2012 and use in asp.net c#(web) please help me
Posted
Updated 10-Sep-14 23:02pm
v2
Comments
Stephen Hewison 11-Sep-14 4:33am    
What have you tried so far, what problems have you run into?
misaqyrn9677 11-Sep-14 5:05am    
I am learning to remove, insert, and edit records in the database have problems
misaqyrn9677 11-Sep-14 5:14am    
DataClassesDataContext dbinsert = new DataClassesDataContext();
var query = (from tbl in dbinsert.TblMisaqs
where tbl.Name == "misaq"
select tbl).First();
query.Name = "soaib";
dbinsert.SubmitChanges();
this code in linq and how to convert to lambda
convert this code for answer this question
dbinsert.Connection.Close();

1 solution

To get start refer this article. This describes Simple SELECT, INSERT, UPDATE and DELETE Using LINQ to SQL.

http://www.c-sharpcorner.com/UploadFile/3d39b4/simple-select-insert-update-and-delete-using-linq-to-sql/[^]
 
Share this answer
 
Comments
misaqyrn9677 11-Sep-14 5:36am    
Very grateful that you introduced me to this page:
It helped me to remove and insert a record into the problem only happened
Gihan Liyanage 11-Sep-14 5:48am    
I couldn't understand what you said by "remove and insert a record into the problem only happened"
And its great if you click on Accept answer, if I helped you.
misaqyrn9677 11-Sep-14 6:17am    
for update record usinf below code

DataClassesDataContext dbedit = new DataClassesDataContext();
var query = dbinsert.TblMisaqs.Where(y => y.Name == "misaq").First();
query.Name = "nar";
dbedit.SubmitChanges();
dbedit.Connection.Close();

and i want write code for insert new record
i cant using for linkin give me ok
please helping me
Gihan Liyanage 11-Sep-14 6:22am    
Still I cant understand what you want to do from your words, Any way I think you need to build up the insert part.So the link has explained the insert part

The INSERT Operation

private void AddNewCourse()
{
//Data maping object to our database
OperationDataContext OdContext = new OperationDataContext();
COURSE objCourse = new COURSE();
objCourse.course_name = "B.Tech";
objCourse.course_desc = "Bachelor Of Technology";
objCourse.modified_date = DateTime.Now;
//Adds an entity in a pending insert state to this System.Data.Linq.Table<tentity>and parameter is the entity which to be added
OdContext.COURSEs.InsertOnSubmit(objCourse);
// executes the appropriate commands to implement the changes to the database
OdContext.SubmitChanges();
}
misaqyrn9677 12-Sep-14 4:14am    
very thanks mr

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