2013-05-02 210 views
1

我的搜索存在问题。我想尽快解释。SQL Server 2005查询

我插入新记录sucsessfully到我的员工表,我从另一个表格列出此表。一切都好。我也看到了我在SQL Server中的记录。

但是在我的列表中,我有搜索条件用于用户搜索和列表。我可以使用窗体onshow属性看到新记录,但是我的搜索sql不显示新记录,只显示旧记录。

任何人都可以帮助我吗?

pl.Close; 

pl.SQL.Clear; 

pl.SQL.Add('select * from employee where active like ' +QuotedStr(statuscombo.Text+'%') + 

              (' and name like ' +QuotedStr(name.Text+'%')  + 
              (' and region like '+QuotedStr(region.Text+'%') + 
              (' and subregionlike ' +QuotedStr(subregion.Text+'%') + 
              (' and departman like ' +QuotedStr(dep.Text+'%') + 
              (' and id like ' +QuotedStr(id.Text+'%'))))))) ; 

pl.Open; 

回答

1

可能的原因:

  • 也许新的记录有一些NULL字段因此得到由 过滤掉你的WHERE子句?
  • 或者,也许你用来插入新的 记录不会更新数据库?

您是否可以使用SQL Server Management Studio在表中查看您的记录?

+0

非常感谢你最大 你很好。我编辑了我的Null字段,问题已解决。 – 2013-05-02 09:21:19

+0

@HakanSubaşı我很高兴你解决了你的问题:-) – Max 2013-05-02 09:23:42

+0

@HakanSubaşı请问为什么我的回答不再是被接受的答案? – Max 2013-05-02 19:07:53