views:

89

answers:

1

I am setting the Address of a class generated by Linq 2 Sql and when I try to SubmitChanges(), the sql query it generates is:

Update Users
Set Address = @po
Where 0 = 1
--@po: Input VarChar (Size = 15; Prec = 0; Scale = 0) [123 45th Street]

I can't figure out why I am getting Where 0 = 1.

+2  A: 

This can happen when your object model differs from the database even by one property.

Is it possible that Address is nullable in the database and not in your model, or the other way around? Or the type differs, say ntext vs nvarchar, etc? In some cases it can be another unrelated property...think back to the last change to the database or model you made, make sure that's in sync.

Nick Craver
I will take a look, but is it a difference between one property on the table I am trying to update or the whole database?
Xaisoft
@Xaisoft - Almost always related to the table you're updating, but I've seen stranger things happen.
Nick Craver
Thanks, that was it.
Xaisoft