Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello ,

I had made a databse application , in one of my form , i had two search criteria , one search by partyname , which will fetch a data from demo table : the code is
VB
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        ds.Clear()
        Da = New OleDb.OleDbDataAdapter("Select * from demo where PartyName = '" + txtspartyname.Text + "'", Cnn)
        Da.Fill(ds, "demo")
        DataGridView1.DataSource = ds.Tables(0)


    End Sub

the othere criteria is to search by customername , wgich will fetch the data from "sales" table : The Code
VB
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        ds.Clear()
        Da = New OleDb.OleDbDataAdapter("Select * from sales where CustomerName = '" + TextBox6.Text + "'", Cnn)
        Da.Fill(ds, "sales")
        DataGridView1.DataSource = ds.Tables(0)

    End Sub

Both Button work fine,

The problem is that if i search by "partyname" , the result is display in grid view , but when i go to search by "customername" , the previous "demotable" is still there in datagridview , so my search criteria doesn't give me any result , same case if i go for search by "CustomerName" , the result are display but when i go to search by "Partyname " the prvious "Sales table " is still present . ..Hope u got wht me trying to . Plz Help me out...
Posted
Updated 6-Sep-12 21:10pm
v2

hiii,

instead of
ds.clear()

write
ds=new DataSet()
 
Share this answer
 
try this instead of Clear() use Reset()
VB
ds.Reset()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900