C# Winforms ADO.NET - DataGridView INSERT starting with null data

Posted by Geo Ego on Stack Overflow See other posts from Stack Overflow or by Geo Ego
Published on 2010-05-03T16:36:46Z Indexed on 2010/05/03 16:38 UTC
Read the original article Hit count: 475

Filed under:
|
|
|

I have a C# Winforms app that is connecting to a SQL Server 2005 database. The form I am currently working on allows a user to enter a large amount of different types of data into various textboxes, comboboxes, and a DataGridView to insert into the database. It all represents one particular type of machine, and the data is spread out over about nine tables.

The problem I have is that my DataGridView represents a type of data that may or may not be added to the database. Thus, when the DataGridView is created, it is empty and not databound, and so data cannot be entered. My question is, should I create the table with hard-coded field names representing the way that the data looks in the database, or is there a way to simply have the column names populate with no data so that the user can enter it if they like? I don't like the idea of hard-coding them in case there is a change in the database schema, but I'm not sure how else to deal with this problem.

© Stack Overflow or respective owner

Related posts about winforms

Related posts about c#