Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > C#: DataGridView: Primary Key Column (varchar): On Insert, Column Does Not Allow Nulls
 

C#: DataGridView: Primary Key Column (varchar): On Insert, Column Does Not Allow Nulls

Hi Guys

I have a DataGridView bound to a DataSet, the DataSet contains a primary key column of type VARCHAR(16) and one other column of type TEXT. In this instance the primary key column is actually to be editable by the user, it is not an identity column, and doesnt have a default value.

When I go to insert a row on the DGV I fill out the value for the PK column, and I put some data in the TEXT column, however, when I press tab to drop off the row and "insert" it, i get "Column * does not allow nulls" and then the new row disappears.

Any clue as to how I can fix this, the column is definitely not empty, and it's not violating a unique constraint, so I am unsure why its throwing this exception.

I have been googling for a while, I set the AllowDBNulls property on the DataSet column but that didnt work either. 


Luke


luke.wallace  Friday, October 02, 2009 9:12 AM
It is probably also worth mentioning,

The DataSet is generated from an SqlDataAdapter, I use FillSchema, and then Fill.

The DataSet also contains relations, the table I am having problems with is a child of a parent table, the relation exists for the Parent to Child relationship.


Luke
luke.wallace  Friday, October 02, 2009 9:18 AM

You can use google to search for other answers

Custom Search

More Threads

• ToolStripComboBox displays in incorrect location
• The Server is not showing anything!
• Provided organisms too large
• Default Publish Setting
• How do you put your creature on the game?
• Server
• Merging two files (only just started using win forms)
• problem with the update of the IssueVision
• Get the Run time Created controls of ids
• find applications and properties that run on PC