how can we save the header of a datagridview in the database without adding a new row in the database?

how can we save the header of a datagridview in the database without adding a new row in the database?,database,datagridview,vb.net-2010,datagridviewcolumn,Database,Datagridview,Vb.net 2010,Datagridviewcolumn,This is what our form looks like: InstructorsID CourseCode Section Surname FirstName MiddleName Date1 Date2 Date3 Date4 Date5 Date6 Date7 Date8 Date9 TotalAbsent Present EquivalentGrade Alex Comp100 DCIT-1b Bancil Lenrick Malabanan Check Check Check Check Uncheck Uncheck Check Uncheck Check 3 6 83 The columns that has a name "DATE" are checkboxes

This is what our form looks like:

   InstructorsID    CourseCode    Section    Surname    FirstName    MiddleName    Date1    Date2    Date3    Date4    Date5    Date6    Date7    Date8    Date9    TotalAbsent    Present    EquivalentGrade     
    Alex            Comp100        DCIT-1b   Bancil     Lenrick      Malabanan     Check    Check    Check   Check     Uncheck  Uncheck  Check    Uncheck  Check        3             6             83   

The columns that has a name "DATE" are checkboxes and it represent the inputted value in the text box. We wanted to save the header of a datagridview in the database to the new fields that we added to the database.

And this is what our database looks like :

  InstructorsID    CourseCode    Section    Surname    FirstName    MiddleName    DateA    Date1    DateB    Date2   DateC    Date3    DateD    Date4    DateE    Date5    DateF    Date6    DateG    Date7    DateH    Date8    DateI    Date9    TotalAbsent    Present    EquivalentGrade     
    Alex            Comp100        DCIT-1b   Bancil     Lenrick      Malabanan  06/02/14  Check  06/03/14   Check  06/04/14    Check  06/05/14   Check  06/06/14 Uncheck  06/07/14  Uncheck  06/08/14  Check  06/09/14  Uncheck  06/10/14  Check        3             6             83  

We want this to happen to our database. When you pressed the button save, the header will be saved in the database. The case is that when you pressed the save button and you look at your database you can see a new added row in the database . Can anyone please help us ! we've been trying to figure out what to do but until now we don't get to solved it!


#1

It is fundamentally wrong to just "save from grid to database". Database is comprised of tables, relations between those tables, stored procedures, views etc. The data in the database must follow the atomicity principle. This basically means, that every transaction in database must be treated as a complete whole. This means, that if you want to do something in your database, that involves multiple inserts/deletes/updates this represents a transaction and if one of e.g. inserts fails, everything is revoked (this is called "database rollback"). If everything goes well, the database then applies the desired changes to the data via so-called "database commit". The other, very important thing you must always keep in mind is that every database field should have only one value. So if you are storing the name of a person, you actually need two database fields: FirstName and LastName. If you want to complicate our life even further you obviously have to include MiddleName, MaidenLastName etc.

How is this relevant? Gridviews are used to present data. They serve as a window into your data and usually make data useful. Sometimes people also populate gridviews in such way, that they create 1 column (let's call it Name) and then show FirstName+" "+LastName in that column. There is nothing wrong with this, but in your case, this presents a problem because you can create orange juce from an orange but cannot recreate the orange back from juice..

Datagridview is a WinForms control and is, as such able to present data from various datasources. Which database/datasource are you using?

I'm afraid you have provided insufficient information for my answer to be more thorough. I can however say,:

  1. that your problem is probably more specific and you will have to provide additional details.
  2. you shouldnt change the database schema based on user input
  3. if you really need this kind of behavior, you will need to familiarize yourself with your database's DML (data manipulation language - for manipulating data) and DDL (data definition language - for changing schema, altering other schema-related issues).

Feel free to expand your question or to ask further.


#2

Ayub si sir martin nagbigay na ng points kung pano gagawin... =D

#3

I'm sorry but I don't understand what you just wrote:)