if ..........<>'' then
sqlstr:=' ';
if .................<>'' then
sqlstr:=sqlstr+ ''''''''''''''';
....................................
sqlstr:=' ';
if .................<>'' then
sqlstr:=sqlstr+ ''''''''''''''';
....................................
解决方案 »
- 如何把读出来的值转化成字符串啊?
- 修改表中的多条数据,怎么修改?
- quickreport在预览时怎么只有8条数据出来,我数据库里有208条记录的,是不是哪里限制了
- 关于DBGrid的应用
- 学delphi是否的有pascal语言基础
- 如何申明一个全局变量,能在整个程序中用。
- 救命啊!!局域网通信高手请进!高分求一方案的解决办法!
- 哪有象IE历史记录那样的控件下载?(可以直接读出历史记录)
- 为什么我的statusbar没有反应
- 如何依次调用几个Edit的内容
- 本人已开发出CRM客户关系管理系统,希望和你讨论其市场问题?
- 怎样让新建的form像OpenDialog一样,总在最前,而且不允许点击其他form,否则beep ?
Str_SQL := 'Select * from TableName where ' ;
Str_SQL := Str_SQL + Edit1.Text + ' ' + ComboBox1.Text + ' '+ #39 + Edit2.Text + #39;//如果是字符型、时间的,就叫#39,否则不加;
再这样循下去,但是,注意,下边就要加 And Or 等了,也用一个控件就可以;
//Edit1.text -> 字段名;
//ComboBox1.Text ->是逻辑条件;
//Edit2.Text ->条件;
Query.SQL.Add(Str_SQL);
Query.Open;
我的email:[email protected]
我的email:[email protected] 谢谢!
还可以用子查询
var
xm1,xm2,bj1,bj2,nj1,nj2:string;
xmb,bjb,njb:boolean;
rpt:integer;
begin
xm1:=edit2.text;
bj1:=combobox3.text;
nj1:=combobox4.text;
table1.DisableConstraints;
table1.First;
while not table1.eof do begin
xm2:=table1.fieldbyname('name').asstring;
nj2:=table1.fieldbyname('grade').asstring;
bj2:=table1.fieldbyname('class').asstring; if length(xm1)=0 then xmb:=true
else if RadioGroup1.ItemIndex=0 then
xmb:=comparetext(xm1,xm2)=0
else xmb:=pos(xm1,xm2)>0; if length(nj1)=0 then njb:=true
else if RadioGroup1.ItemIndex=0 then
njb:=comparetext(nj1,nj2)=0
else njb:=pos(nj1,nj2)>0; if length(bj1)=0 then bjb:=true
else if RadioGroup1.ItemIndex=0 then
bjb:=comparetext(bj1,bj2)=0
else bjb:=pos(bj1,bj2)>0; if xmb and bjb and njb then
if RadioGroup1.ItemIndex=0 then break
else
begin
rpt:=application.messagebox('是否这个人','请确认',mb_okcancel);
if rpt=idok then break;
end;
table1.Next;
end; table1.EnableConstraints;
if length(xm1+bj1+nj1)=0 then showmessage('查询条件为空')
else if table1.eof then showmessage('没有找到')
else showmessage('已经找到');
end;xm,姓名
bj,班级
nj,年级