Home > Software design >  Saving data from datagridview to a dataset
Saving data from datagridview to a dataset

Time:08-27

I'm very new to C# and visual studio (I have only used python up until this point) The issue that I have is I want to quickly populate a datatable in my dataset with test data. The method so far was to create a data grid view of said table (PATIENT) fill in the info and either exit the program or press a button to save. exiting the program doesn't save for me and I am not sure what code will allow me to save from a data grid view. table hierarchy for all the data entered

Please ignore the boxes behind this was just trying to get data to save

TL:DR Anyone know of the correct code to save a datagridview to a dataset. Its completely possible I'm not even using a dataset correctly -_-

CodePudding user response:

A DataSet is 'an in-memory cache of data retrieved from a data source' (https://docs.microsoft.com/en-us/dotnet/api/system.data.dataset?view=net-6.0). In your case, it sounds like you haven't bound to an external 'data source'; the grid is empty and the user types in the information. You will need to persist that data out to some sort of storage, most likely a database, if you want it to persist between sessions.

  • Related