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

VulpesRank #55 · 29.2K reputationPosted Apr 3, 2012, 8:59 AM EDT
Luke Baker20 reputationPosted Apr 3, 2012, 10:05 AM EDT
"Dynamic SQL generation is not supported against multiple base tables." Any idea how to avoid this??
Sam HobbsRank #107 · 20.5K reputationPosted Apr 3, 2012, 11:04 AM EDT
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 Baker20 reputationPosted Apr 3, 2012, 11:09 AM EDT