Im currently building a program to view and update data from a database using data grid views. I have text boxes and combo boxes to filter the data in the data grid view. This is achieved with the below code -
[code]
public void con(string command, DataGridView dgv, bool update)
{
string conStr = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\NTO.mdf;Integrated Security=True;User Instance=True";
SqlDataAdapter da = new SqlDataAdapter(command, conStr);
SqlCommandBuilder cBuilder = new SqlCommandBuilder(da);
DataTable dt = new DataTable();
da.Fill(dt);
BindingSource bSource = new BindingSource();
bSource.DataSource = dt;
dgv.DataSource = bSource;
}
[/code]
The problem being is getting to update the data when the data in the data grid view has been changed. I understand that you have to do dataAdapter.Update(datatable) but trying to do this when calling the con() method proves difficult??
ANY IDEAS??
Loading
VulpesPosted Apr 3, 2012, 12:59 PM
Luke BakerPosted Apr 3, 2012, 3:09 PM
Sam HobbsPosted Apr 3, 2012, 3:04 PM
If I understand the problem, then the solution is to create insert and update commands explicitly. If you need help with that then please create a new thread. If you refer to the documentation then I think it will be clear. Thereare many articles in this web soite that will help you.
Luke BakerPosted Apr 3, 2012, 2:05 PM
"Dynamic SQL generation is not supported against multiple base tables." Any idea how to avoid this??