M
M
matros972017-10-31 15:07:19
.NET
matros97, 2017-10-31 15:07:19

DataGridView save changes to DB - C#?

Good morning! Tell me how, when I click on the "Save" button, save the changes to the database that I made in the DataGridView.
This is how I get the data:

public DataTable SelectNowYear()
{
  DataTable dt = new DataTable("table");

  SQLiteConnection connection = new SQLiteConnection(connect_db);

  SQLiteCommand command = new SQLiteCommand("SELECT * FROM `"+ tablename +"` WHERE Year="+year, connection);

  connection.Open();

  SQLiteDataAdapter dAdpt = new SQLiteDataAdapter(command);

  dAdpt.Fill(dt);

  connection.Close();

  return dt;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Chernyakov, 2017-10-31
@Kubatai

When using ADO.NET, you shouldn't have much trouble changing data in the database. See related links: Getting and modifying data in
ADO.NET Updating
data sources using Da objects... updating data in the database. PS For data security, I advise you to prohibit the execution of queries and use only procedures.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question