Hi Friends...
I have a written a function in a separate class file which return
Dataset. This function help me to bind the datagridview.
public DataSet dsreturn_edit(DataSet ds, String qry)
{
try
{
if (conn.State == ConnectionState.Closed)
{ conn.Open(); }
OleDbCommand itemcmd = new OleDbCommand(qry, conn);
OleDbDataAdapter adapter = new OleDbDataAdapter(itemcmd);
adapter.Fill(ds, "DailyData");
return ds;
}
catch (Exception ex)
{
MessageBox.Show("There was an error loading data to dataset. DETAIL: " + ex.ToString(), "My Application");
}
finally
{
conn.Close();
}
return ds;
}
In the form load event I am binding the Datagridview like this
BindingSource bs = new BindingSource();
DataSet ds = new DataSet();
bs.DataSource = dc.dsreturn(ds, "Select ID,FullName,Mobile,DOB,Gender,Status from Family").Tables[0];
dataGridView1.DataSource = bs;
My requirement is to update the datagridview with a button click. I need to use like this.
adapter.Update(dataTable);
Problem is that, in the form i am not using any
adapter object. My ultimate is to update the DB with
Update Keyword