i am pasting the code in which i am finding the error
this is happening when i click on the update button of the datagrid which is fired when i click the edit button
public void BindData()
{
OleDbDataAdapter da = new OleDbDataAdapter("SELECT *FROM CMRS_BUSINESSAREA_MASTER","Provider=MSDAORA.1;User ID=meter_reading;Password=colony;Data Source=windev;OLEDB.NET=true;" );
DataSet ds = new DataSet();
da.Fill(ds);
DataGrid1.DataSource = ds.Tables[0].DefaultView ;
DataGrid1.DataBind();
}
public void Edit_DataGrid1(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
// We use CommandEventArgs e to get the row which is being clicked
// This also changes the DataGrid labels into Textboxes so user can edit them
DataGrid1.EditItemIndex = e.Item.ItemIndex;
// Always bind the data so the datagrid can be displayed.
BindData();
}
public void Cancel_DataGrid1(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
// All we do in the cancel method is to assign '-1' to the datagrid editItemIndex
// Once the edititemindex is set to '-1' the datagrid returns back to its original condition
DataGrid1.EditItemIndex = -1;
BindData();
}
public void Update_DataGrid1(object source,System.Web.UI.WebControls.DataGridCommandEv entArgs e)
{
//try
//{
string str = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
OleDbConnection con1 = new OleDbConnection();
con1.ConnectionString = str;
TextBox txtAREADESCRIPTION =(TextBox) e.Item.Cells[1].Controls[0];
string strUpdateStmt;
strUpdateStmt = "UPDATE CMRS_BUSINESSAREA_MASTER SET" + "CBM_BUSAREA_DESC = '" + txtAREADESCRIPTION.Text + "' " + "WHERE CBM_BUSAREA_CODE = " + e.Item.Cells[0].Text;
Response.Write("strUpdateStmt");
cmd = new OleDbCommand(strUpdateStmt,con1);
con1.Open();
cmd.ExecuteNonQuery();
DataGrid1.EditItemIndex = -1;
BindData();
}
//catch(Exception e)
//{
// Console.WriteLine(e.Message.ToString());
//}
//}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.cmd = new System.Data.OleDb.OleDbCommand();
this.con1 = new System.Data.OleDb.OleDbConnection();
this.addbtn.Click += new System.EventHandler(this.addbtn_Click);
this.updtbtn.Click += new System.EventHandler(this.updtbtn_Click);
this.delbtn.Click += new System.EventHandler(this.delbtn_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void addbtn_Click(object sender, System.EventArgs e)
{
string str = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
OleDbConnection con1 = new OleDbConnection();
con1.ConnectionString = str;
OleDbCommand cmd = new OleDbCommand("Insert into cmrs_businessarea_master values('"+TextBox1.Text+"','"+TextBox2.Text+"')",c on1);
con1.Open();
cmd.ExecuteNonQuery();
con1.Close();
BindData();
}