Questions tagged [insertonsubmit]

37 questions
26
votes
2 answers

NullReferenceException when doing InsertOnSubmit in LINQ to SQL

In my database I have a table called StaffMembers when I bring this into my .net Project as through linq-to-sql an entity class StaffMember is created Now I have also created a partial class StaffMember in my project also, to add extra properties…
soldieraman
  • 2,630
  • 7
  • 39
  • 52
5
votes
4 answers

Can't find InsertOnSubmit() method

I'm new to Entity Framework, and I'm think there is something that I misunderstand here. I'm trying to insert a row in a table, and everywhere I found code example, they call the method InsertOnSubmit(), but the problem is that I can't find anywhere…
Hugo
  • 2,077
  • 2
  • 28
  • 34
4
votes
3 answers

submit text from "div contenteditable"

I'm trying to find a working solution, but there is nothing useful at the moment. I have the following form:
John Johansen
  • 131
  • 1
  • 11
3
votes
1 answer

How do I rollback a failed InsertOnSubmit? (VB.NET LINQ)

I'm having a problem with undoing a failed InsertOnSubmit when SubmitChanges fails. Here's the code: Dim NewFac As New t_Facility With {.FK_Instance_ID = guInstance_ID, .FK_AccountType_ID = guAccountType_ID, …
G.Williams
  • 63
  • 7
2
votes
1 answer

linq delete, insert, submit

i am wondering if i need to continually call SubmitChanges() when i run sequential delete/insert statements on the same data store: db.SomeTable.DeleteAllOnSubmit( db.SomeTable.Where( p => p.PartID == part.PartID )…
horace
  • 938
  • 9
  • 20
2
votes
0 answers

"A duplicate value cannot be inserted into a unique index. [ Table name = Order,Constraint name = PK_Order ]"

I am building a Windows Phone Application using Mango with SQLCE 4.0 (I think). I get this error when I am trying to submit a new OrderItem, with context.SubmitChanges() command. A duplicate value cannot be inserted into a unique index. [Table …
2
votes
1 answer

Linq to SQL "Cannot insert the value NULL" when NOT NULL!

I am massively in need to help. I have spent an entire day when I do not have even an hour to waste on a project. I have a Linq to SQL data layer and am doing a simple insert into the DB using the following code: using (var odc = new…
webwires
  • 2,572
  • 3
  • 26
  • 44
2
votes
1 answer

DLINQ- Entities being inserted without .InsertOnSubmit(...)?

I ran into an interesting problem while using DLINQ. When I instantiate an entity, calling .SubmitChanges() on the DataContext will insert a new row into the database - without having ever called .Insert[All]OnSubmit(...). //Code…
Charles
  • 6,199
  • 6
  • 50
  • 66
2
votes
1 answer

[LINQ]InsertOnSubmit NullReferenceException

I have a rather annoying issue with LinqToSql. I have created a class that is derived from the class in the DataContext. The problem is that as soon as I use "InsertOnSubmit(this);" on this derived class I get a NullReferenceException. I've seen…
Oskar Kjellin
  • 21,280
  • 10
  • 54
  • 93
2
votes
1 answer

Linq to SQL: How to get values added thru InsertOnSubmit but before SubmitChanges?

Having trouble getting this. I need get the values that I have added to a table entity through the InsertOnSubmit method. However I have not yet invoked SubmitChanges on the table. So, I have this in a loop:…
user259286
  • 977
  • 3
  • 18
  • 38
1
vote
3 answers

ASP.net MVC Linq-to-SQL Insertion Problems

TLDR Summary I'm having a few issues with ASP.net MVC's InsertOnSubmit() function. How do you build and insert new objects into the database without running into key constraints? Steps to Reproduce I've gone ahead and created a simple…
ArtOfTheSmart
  • 330
  • 2
  • 12
1
vote
1 answer

LINQ to SQL: Insert into Primary and Foreign table

I'm trying to insert data into a primary table and a dependent table at the same time. A database relationship does exist between the two tables, and table Employee have an Identity column as the Primary Key. I'm trying: Database.Employee…
Cameron Castillo
  • 2,712
  • 10
  • 47
  • 77
1
vote
2 answers

LinqToSql - "insert on submit"

I'm trying to insert a row in to one of my tables, so I look over the web to find an example for using the DATACONTEXT and found this one: protected void buttonSave_Click(object sender, EventArgs e) { using (NorthwindDataContext context = new…
yoni
  • 47
  • 1
  • 2
  • 7
1
vote
1 answer

Linq InsertOnSubmit, DeleteOnSubmit and update not working

I read a couple of posts related to InsertOnSubmit is not working but none of them resolve my issue. Below is my code, I have insert manually a record in my BackupPlan table and when i run a linq select the record from database and the 2 new records…
1
vote
1 answer

how to update a database using linq to sql

I am trying to change a value stored in a database but I am unsure on how to do that, using (DataClassesDataContext dataContext = new DataClassesDataContext()) { int accounttype = 1; int id = 123; //Search database for record based on round…
brian4342
  • 1,265
  • 8
  • 33
  • 69
1
2 3