Thanks A lot Dear it worked
Thanks
Dear an other little help from u is required
my follwing code for update record is not working
PurchaseDa.Update(PurchaseDs, "DisplaycenterData")
DataGridPurchase.Update()
DataGridPurchase.Refresh()
to update a new record i used following code to add record
Me.BindingContext(PurchaseDt).AddNew()
then i insert data into related textboxes, and press update, but it only update data in Cashe, after restarting program the new added data is not updated.
to fix the problem i tried also some zigzag non-standard way to update record properly. from the Code Below u may understand that what is the mistake i m doing with simple and standard update function.
the working code for update record is
'Da= dataadapter, Ds=Dataset,
CompanyDa.Update(CompanyDs, "DisplayCenterData")
DataGridCompany.Refresh()
DataGridCompany.Update()
'Following steps i learnt from practical when i was trying to update record, it was not updating then i tried following steps menualy, with hands (not programatically), and at least i succeded, then i tried them to write in code and here i also succeded to update record. these steps are
'searching any record (txtsearch is Blank, mean following code returns all records)
CompanyDt.DefaultView.RowFilter = "CompanyName like '" & txtSearch.Text & "%'"
'then moving between records, one next and one previous
Me.BindingContext(CompanyDt).Position -= 1
Me.BindingContext(CompanyDt).Position += 1
'then i searched last added Record as 'CmpnyNm' is a variable equals to last added record
CompanyDt.DefaultView.RowFilter = "CompanyName like '" & cmpnyNm & "%'"
''then after i used once again UPdate statement
CompanyDa.Update(CompanyDs, "DisplayCenterData")
CompanyDt.Clear()
'now i needed to reload data into datatable so that i used following code
CompanySql = "Select * from company order by CompanyID"
CompanyDa = New OleDb.OleDbDataAdapter(CompanySql, CompanyConn)
CompanyCmb = New OleDbCommandBuilder(CompanyDa)
CompanyDa.Fill(CompanyDs, "DisplayCenterData")
CompanyDt = CompanyDs.Tables("DisplayCenterData")
DataGridCompany.DataSource = CompanyDt
DataGridCompany.DataSource = CompanyDt
txtCompanyID.DataBindings.Clear()
txtCompanyName.DataBindings.Clear()
txtCompanyID.DataBindings.Add("text", CompanyDt, "Companyid")
txtCompanyName.DataBindings.Add("text", CompanyDt, "CompanyName")
Dear plz Help, yes some text boxes data is auto ganerated thats why thay dont Recieve 'focus' (focus event) and thats why thay cant be update in datagrid or datatable (i Thinks so), and because of that i used one record next and one record previous code before update, so that data from autogenerated text boxes should fix itself into datatable and Datagrid.
ur help is apriciated