请问下面这段代码怎么转成存储过程(50分)

  • 主题发起人 babyboom
  • 开始时间
B

babyboom

Unregistered / Unconfirmed
GUEST, unregistred user!
with adotable do
begin
Close;
SQL.Clear;
SQL.add('select * from dict where 1=1 ');
if Edit1.text<>'' then
SQL.add('and cola='''+Edit1.text+''' ');
if Edit2.text<>'' then
SQL.add('and cola='''+Edit2.text+''' ');
if Edit3.text<>'' then
SQL.add('and cola='''+Edit3.text+''' ');
if Edit4.text<>'' then
SQL.add('and cola='''+Edit4.text+''' ');
Open;
end;

现在需要调用存储过程实现以上代码的功能,怎么实现??
 
在存储过程中用参数:4个EDIT。TEXT
对四个EDIT的值进行判断
 
sorry

源码写错了
应该是:
if Edit1.text<>'' then
SQL.add('and cola='''+Edit1.text+''' ');
if Edit2.text<>'' then
SQL.add('and colb='''+Edit2.text+''' ');
if Edit3.text<>'' then
SQL.add('and colc='''+Edit3.text+''' ');
if Edit4.text<>'' then
SQL.add('and cold='''+Edit4.text+''' ');
 
create procedure searchname @sql varchar(1000),@S1 varchar(100),@S2 varchar(100),
@S3 varchar(100),@S4 varchar(100)
As
begin
if @S1<>'' Select @sq=@sql+'and cola='''+@S1+''''
if @S2<>'' ...
end
 
呵呵。UP
 
forgot2002, 你的答案好象和我的源代码的方法有出入。
请再仔细看看
 
不要用=
改用Like
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
609
import
I
I
回复
0
查看
505
import
I
顶部