V
V
Vladdden2020-05-28 09:19:08
C++ / C#
Vladdden, 2020-05-28 09:19:08

How to store data from a database offline in a Win Forms application?

There is an application on Win Forms in which there is a request to a DB and an output of contents of tables through DataGridView.

private void buttonOK_Click(object sender, EventArgs e)
        {
            if (СomboBoxTables.SelectedItem == null) return;
            adapter = new SqlDataAdapter("SELECT * FROM [" + СomboBoxTables.SelectedItem.ToString() + "]", conn);
            new SqlCommandBuilder(adapter);
            dtMain = new DataTable();
            adapter.Fill(dtMain);
            DataGridView1.DataSource = dtMain;
        }

It is necessary to make sure that the data is available in the final .exe file, regardless of the local connection of the computer (so that the program is autonomous and stores data since the last connection to the database). I suppose to export the database into a single sql query, and then read this file line by line with a script and enter the data into the database.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
#
#, 2020-05-28
@Vladdden

in exeno way. if you only save to a separate file - json, csv, xml.. in fact there are many options, at least file your own format or into a lightweight embeddable database ps popular options are SQLite, MS SQLCE , LiteDB .. in fact there are many options pps even Access - the joke is that it is not Access itself that is primary, but the engine. it is built into any Windows by default. so many generations of ppps


but I don't know how to "copy" these same "pieces" from the common archive base.
still look here (unless of course you have MS SQL, which can be assumed from various passages)
https://docs.microsoft.com/en-us/sql/integration-s...
https://docs.microsoft.com /ru-ru/sql/integration-s...
and even with a bang, you can use LINQpad for the same purposes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question