关于使用edit.text的内容为条件查询的问题 (50分)

  • 主题发起人 主题发起人 dfwer
  • 开始时间 开始时间
D

dfwer

Unregistered / Unconfirmed
GUEST, unregistred user!
根据edit1、edit2等中的内容为条件从一个表a.dbf查询符合条件的记录并显示。
部分代码如下:
Query1.close;
query1.sql.clear;
if (edit1.text<>'') and (edit2.text='') and (edit3.text='') then
query1.sql.Add('select * from a where Wtgddm='+'''+edit1.text+''');
if (edit2.text<>'') and (edit1.text='') and (edit3.text='') then
query1.sql.Add('select * from a where Wtzqdm='+'''+edit2.text+''');
if (edit3.text<>'') and (edit1.text='') and (edit2.text='') then
query1.sql.Add('select * from a where Wthtxh like '''+edit3.text+'''');


query1.open;
edit1.clear;
edit2.clear;
edit3.Clear;
请问为什么DBGRID中为什么没有记录(能显示表的结构,就是说符合条件的记录数是0!!)?可是表a中是有的,哪位帮我看看什么地方有问题?
 
... where Wtgddm='''+edit1.text+''''
 
语句有问题,根据下面的改一下就行了。
'select * from sjswt where Wtzqdm='''+edit2.text+'''';
 
select * from sjswt [?]
select * from a [?]
 
前面两个查询语句对了,最后一句不对:
if (edit3.text<>'') and (edit1.text='') and (edit2.text='') then
query1.sql.Add('select * from a where Wthtxh like '''+edit3.text+'''');
我是想查询字段Wthtxh的前六位和edit3.text中的内容相同的记录!
先谢上面几位了!
 
if (edit3.text<>'') and (edit1.text='') and (edit2.text='') then
query1.sql.Add('select * from a where Wthtxh like ''%'+edit3.text+'%''');
 
(edit1.text<>'') and (edit2.text='') and (edit3.text='')
我看是三个条件都不符合,所以没有查询语句。
比如EDIT2.text=' ',就会这样
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
782
import
I
后退
顶部