I have a data grid view and i want to know how i can have the data entered saved to a file... a .ini file? whatever type of file that can save a database of information entered into the data grid view
thanks a bunch,
Phil
Printable View
I have a data grid view and i want to know how i can have the data entered saved to a file... a .ini file? whatever type of file that can save a database of information entered into the data grid view
thanks a bunch,
Phil
Are you intending to read or display this data anywhere other than this grid? If not then the easiest way would be to bind your grid to a DataSet and use its ReadXml and WriteXml to load and save the data with one line of code. An XML file will be a bit larger than a comparable plain text file but it also stores a lot more type information for the data, not just the data itself.
Having said that, you'd generally be better off using an actual database rather than jusr data files. Even an Access database offers you greater functionality than a data file, but something like SQL Server Express provides more functionality again. Of course, with additional functionality comes additional overhead and that may be undesirable.
no, it wouldn't be read by anything else, but it will store passwords so i was wondering if it'd be possible to encrypt it in some sort of way. I wouldn't want to use sql server since i didn't bother to install it since i wouldn't use it for anything else than that, so an xml file would be good.
how can i bind it to a dataset?
Assign the DataSet to the DataSource and the name of the table to the DataMember.
ok, i've set the dataset to the datasource... umm, what's the datamember? name of the table of what?
ugh, sorry for my stupidity i'm tired... i found it thanks a lot
EDIT:
kk, i've done that and now i have a problem. this is my code:
when it opens up the database.xml file, all of the cells are emptyVB Code:
Private Sub SaveDataToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SaveDataToolStripMenuItem.Click DataSet1.WriteXml("database.xml") End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load DataSet1.ReadXml("database.xml") End Sub