Friends I m working with RowFilter, its working good with String Data, and like statements, specially its Autometed functuallity with string data is good, just like in follwing code (it is written in Textbox "txtSearch"s TextChanged Event)

Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged

PurchaseDt.DefaultView.RowFilter = "salePerson like '" & txtSearch.Text & "%'"
   End Sub

this is working good, it search saleperson field in datatable (purchaseDt in my case) as we type text, if we remove text from textbox (txtSearch) then it shows all Rows data from database, same is not with Integer, i tried following code in textChange event of textbox

PurchaseDt.DefaultView.RowFilter = "PUrchaseID=" & txtSearch.Text & ""

it returns data if there is some number or integer in txtsearch, as soon as we remove/clear text from txtSearch textbox it return error,

"Syntax error: Missing operand after '=' operator."

Dear why it is not working just like string data where if there is not any text in text box it return all records, or plz provide any solution so that if there is no number in textbox (RowFilter) then it should be cleared or return all records again or some thing like that

Plz Help

Perhaps something like this:

If txtSearch.Text.Equals("") Then
                PurchaseDt.DefaultView.RowFilter = ""
        Else
                PurchaseDt.DefaultView.RowFilter = "PUrchaseID=" & Integer.Parse(txtSearch.Text)
        End If

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

Answered in the PM you also sent.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.