datagridview control

Solution to “System.Data.InvalidConstraintException: ForeignKeyConstraint” error

If you encounter the following error: System.Data.InvalidConstraintException: ForeignKeyConstraint FK_foreign_key_name requires the child key values (-1) to exist in the parent table. Or The INSERT statement conflicted with the FOREIGN KEY constraint "FK_foreign_key_name ". The conflict occurred in database "YourDatabase", table "dbo.Tablename", column 'YourPrimaryKey'. The statement has been terminated. Probably you are using a Parent-Child table or Master-Detail table.

How to Differentiate Two Cell Values in DataGridView Control

I read a lot of question about this on the forum and thought it’s time to share with you on how to differentiate two cell values in DataGridView control. By default we use the Value property of cells like: QtyOrdered = InvoiceDetails("Qty", e.RowIndex).Value Another is to use the FormattedValue like: QtyOrdered = InvoiceDetails("Qty ", e.RowIndex).FormattedValue But the two code above will not work if you have a condition like If QtyOrdered > InvoiceDetails ("TotalQty", e.RowIndex).Value Then to determine if the Qty Ordered is less than the

How to Create Master/Detail Windows Forms

On my last tutorial I discuss on “How to Display Data in Windows Forms”. This time I will teach you on “How to Create Master/Detail Windows Forms”.

Creating a master/detail form still requires the same method as displaying data in windows forms. Except that we use additional control called “DataGridView”. This control will display the related record known as child form.