Hello. I made a webforms app which shows a datagridview with all users recorded into the database. Everything works fine, except saving the data from dataTable to DataGridView. The dataTable is used just to search entries by a column name, which works
fine as well.
For example, if I'm entering into the database from the program, I can add any much data I want, and it is saved.
If I'm altering the database (adding/changing/deleting data) after making a search, it don't save anymore.
Hers is my code for loading and how the dataTable selects data:
To save the data on the dataGridView, I used this event:
For example, if I'm entering into the database from the program, I can add any much data I want, and it is saved.
If I'm altering the database (adding/changing/deleting data) after making a search, it don't save anymore.
Hers is my code for loading and how the dataTable selects data:
private void Form2_Load(object sender, EventArgs e)
{
this.tableTableAdapter.Fill(this.dbITPDataSet.Table);
}
string connectionString = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\dbITP.mdf;Integrated Security=True;Connect Timeout=30";
using (SqlConnection connection = new SqlConnection(connectionString))
{
if (comboBox1.Text == "User")
{
SqlDataAdapter sda = new SqlDataAdapter("select * FROM [Users] WHERE (User LIKE '" + textBox1.Text + "%')", connection);
DataTable dt = new DataTable();
sda.Fill(dt);
tableDataGridView.DataSource = dt;
}
I've uploaded just a part of the code, all conditions are the same, just the field changes.To save the data on the dataGridView, I used this event:
private void Form2_FormClosed(object sender, FormClosedEventArgs e)
{
tableAdapterManager.UpdateAll(dbITPDataSet);
}
Do you have any ideas? I should pass somehow only changed data to the dataGridView.