0

Possible Duplicate:
What can I do to resolve a “Row not found or changed” Exception in LINQ to SQL on a SQL Server Compact Edition Database?

I am getting this error :-

"Row not found or changed."

My code is here:-

var tab1 = db.Tabl.Single(s => s.ID == ID);
tabl1.ReceivedDateTimeStamp = DateTime.Now;
tabl1.SentDateTimeStamp = null;
tabl1.Status = "RECEIVED";
db.SubmitChanges();

I have also made sure that ID does exist in database. Any help?

A Query from SQL Profiler:- (actual table)

UPDATE [dbo].[Queue]
SET [QueuedDateTimeStamp] = @p8
WHERE ([QueueID] = @p0) AND ([FileName] = @p1) AND ([PNumber] = @p2) AND ([PName] = @p3) AND ([TNumber] = @p4) AND ([AcquireDate] = @p5) AND ([QueuedDateTimeStamp] = @p6) AND ([SentDateTimeStamp] IS NULL) AND ([Status] = @p7)', N'@p0 int,@p1 nvarchar(74),@p2 nvarchar(14),@p3 nvarchar(1),@p4 nvarchar(36),@p5 datetime,@p6 datetime,@p7 nvarchar(6),@p8 datetime', @p0 = 3, @p1 = N'150_5dadccc7-ca5b-4360-aa3e-6ffd3e8bf7b8_123456789-2011_D_20111019 0323 PM', @p2 = N'123456789-2011', @p3 = N'D', @p4 = N'5dadccc7-ca5b-4360-aa3e-6ffd3e8bf7b8', @p5 = 'Oct 19 2011  3:23:00:000PM', @p6 = 'Nov  8 2011  4:34:04:270PM', @p7 = N'QUEUED', @p8 = 'Nov  8 2011  4:41:31:370PM'

Why did it put condition on all the fields? whereas I just need to update record where queueID = '1'

Community
  • 1
  • 1
User13839404
  • 1,803
  • 12
  • 37
  • 46

1 Answers1

0

You probably changed the definition in some of the tables in your database after you generated your LINQ to SQL classes.

Simple solution would be to generate those classes again, but make sure you copy any changes you made to them after generating (i.e. adding custom fields or methods).

A different solution is to recall what you changed in your database since the error started to appear (setting a field from NOT NULL to NULL or vice versa will cause this error), and then make relevant changes in your LINQ to SQL classes.

neeKo
  • 4,280
  • 23
  • 31