Throw insert error: the specified reset is not valid

I am working in a WPF application.

The following is a diagram of the table I'm using:

enter image description here

In this table, file_name is not an identification key, and ID is a column of identifiers.

The following is the code I'm using:

 t_table_name t = new t_table_name
                {
                    file_name = "test"
                };
                dc.t_table_names.InsertOnSubmit(t);
                dc.SubmitChanges();

Error:

 at System.Data.SqlClient.SqlBuffer.get_Int32()
 at Read_Object(ObjectMaterializer`1 )
 at System.Data.Linq.SqlClient.ObjectReaderCompiler.ObjectReader`2.MoveNext()
 at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
 at System.Data.Linq.ChangeDirector.StandardChangeDirector.DynamicInsert(TrackedObject item)
 at System.Data.Linq.ChangeDirector.StandardChangeDirector.Insert(TrackedObject item)
 at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
 at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
 at OMS.MyOrders.Model.MyOrderExecutor.SaveTransactions(List`1 changes)
 at OMS.MyOrders.Model.MyOrderExecutor.SavePartReceiving(List`1 source, String system)

I can’t understand where I am going wrong.

+4
source share
3 answers

I found a solution for this. Actually, the problem was not in the linq query, the problem was in the trigger, which fires when t_table_name is inserted . This trigger then calls the stored procedure, which was used to create the file based on some conditions.

, :

enter image description here

, Execute :

   dc.ExecuteCommand("Insert into t_table_name (file_name) values ({0})", "test3");

: -)

0

? , ...

+3

You must set the primary key identifier. Manually, if not already done.

0
source

Source: https://habr.com/ru/post/1541742/


All Articles