constraintexception

DataGridView System.Data.ConstraintException on row enter

ⅰ亾dé卋堺 提交于 2020-01-17 03:13:44
问题 Just as a starting note: I'm going through an existing app which was passed down to us and trying to go through and fix the bugs. I've been having issues with one particular DataGridView erroring out; giving me a Unique Constraint Exception on the ID. The strange thing is that I don't receive this error when I add the new item to the table, I receive it when I try to select a row (any row, it doesn't have to be the newly added item) in the DataGridView. When you add an item to this table it

My SQL table is set to allow NULL for this column, but when I run it, it says it cannot be NULL. What/Why/How?

本小妞迷上赌 提交于 2019-12-23 19:31:56
问题 so I have quite the odd predicament here. My SQL table is set to allow nulls for my ZipCode column, like so: CREATE TABLE [dbo].[Companies] ( [CompanyId] BIGINT IDENTITY(1,1) NOT NULL PRIMARY KEY, [Name] NVARCHAR(100) NOT NULL, [Address] NVARCHAR (100) NULL, [City] NVARCHAR (50) NOT NULL, [State] NVARCHAR (2) NOT NULL, [ZipCode] INT NULL, [PhoneNum] BIGINT NULL, [CreatedDate] DATETIME2 NOT NULL DEFAULT GetDate() ) This should let me have ZipCode's value as NULL, right? Well, apparently not...