mohi88

mohi88

  • NA
  • 17
  • 0

datagrid update column

May 20 2005 6:52 PM
i have a datagrid which shows a table from a Access DB, the point that every thing is ok but when i ask the datagrid update button to update some values it excute the subroutine update with now erorr but id dose not update the DBand it gose like that for any value in the datagrid, no erorr but no update :(. the kode is down please help and thatnk in advanc ---------------------------------code start-------------------------- private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { OleDbConnection conn; OleDbCommand cmd; //string strSql; int datasay; string strAd; string strUnvan; string strTelefon; int intSayId; intSayId=(int)this.DataGrid1.DataKeys[e.Item.ItemIndex]; TextBox txtAd = (TextBox)e.Item.Cells[1].Controls[0]; TextBox txtUnvan = (TextBox)e.Item.Cells[2].Controls[0]; TextBox txtTelefon = (TextBox)e.Item.Cells[3].Controls[0]; strAd=txtAd.Text; strUnvan=txtUnvan.Text; strTelefon=txtTelefon.Text; conn=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data source= " + Server.MapPath (".") +"\\..\\a2128reem\\[email protected]"); //strSql = "Update ref Set AD=@ad, UNVAN=@unvan, TELEFON=@telefon Where ID=@ID"; cmd=new OleDbCommand("Update ref Set AD=@ad, UNVAN=@unvan, TELEFON=@telefon Where ID=@ID",conn); cmd.Parameters.Add("@ID",intSayId); cmd.Parameters.Add( "@ad", strAd ); cmd.Parameters.Add( "@unvan", strUnvan ); cmd.Parameters.Add("@telefon",strTelefon); conn.Open(); datasay=cmd.ExecuteNonQuery(); conn.Close(); this.DataGrid1.EditItemIndex=-1; yukle(); } private void Page_Load(object sender, System.EventArgs e) { if(!IsPostBack) { yukle(); } } void yukle() { OleDbConnection conn; OleDbDataAdapter oda; DataSet ds; conn=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data source= " + Server.MapPath (".") +"..\\..\\a2128reem\\[email protected]"); oda=new OleDbDataAdapter("select * from ref order by ID Desc ",conn); ds=new DataSet(); oda.Fill(ds); this.DataGrid1.DataSource=ds.Tables[0]; this.DataGrid1.DataBind(); }

Answers (1)