以前的搜索表仍然存在,而od显示的是新表..... [英] Previous search table is still there , instead od showing the new table.....

查看:55
本文介绍了以前的搜索表仍然存在,而od显示的是新表.....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我已经创建了一个数据库应用程序,以我的一种形式,我有两个搜索条件,一个是通过方名搜索的,它将从演示表中获取数据:代码为

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

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


其他条件是按客户名称搜索,wgich将从"sales"表中获取数据:代码


the othere criteria is to search by customername , wgich will fetch the data from "sales" table : The Code

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


两个Button都可以正常工作,

问题是,如果我按"partyname"进行搜索,则结果显示在网格视图中,但是当我按"customername"进行搜索时,以前的"demotable"仍存在于datagridview中,因此我的搜索条件不存在.给我任何结果,如果我按"CustomerName"进行搜索,则显示相同的结果,但显示结果,但是当我按"Partyname"进行搜索时,仍然存在以前的销售表". ..希望你明白我的意思.请帮我...


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...

推荐答案

hiii,

代替
ds.clear()


ds = new DataSet()
hiii,

instead of
ds.clear()

write
ds=new DataSet()


尝试使用Reset()代替Clear()
try this instead of Clear() use Reset()
ds.Reset()


这篇关于以前的搜索表仍然存在,而od显示的是新表.....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆