I am using Paging to show data in datagridview, but when i try to Update any data with updatebutton data should be updated In datagridview
You have Created the OleDbDataAdapter with a Select command only:
adp1 = new OleDbDataAdapter(cmd1);
OleDbDataAdapter requires valid Update, Insert, Delete commands to be used to save the data like this:
adp1.Update(dt);//here I am getting error
You just need to use a OleDbCommandBuilder that will generate the commands for you:
adp1 = new OleDbDataAdapter();
adp1.SelectCommand = cmd1; // cmd1 is your SELECT command
OleDbCommandBuilder cb = new OleDbCommandBuilder(adp1);
EDIT
Since you change the Select command of the OleDbDataAdapter at runtime for paging, what your need is to initialize each time you save data:
private void button1_Click(object sender, EventArgs e)
{
try
{
adp1.SelectCommand = cmd1; // cmd1 is your SELECT command
OleDbCommandBuilder cb = new OleDbCommandBuilder(adp1);
adp1.Update(dt); //here I hope you won't get error :-)
}
catch (Exception err)
{
MessageBox.Show(err.Message.ToString());
}
}