P
paopao7985
Unregistered / Unconfirmed
GUEST, unregistred user!
我用SQL2000数据库
数据库中又SP_YHB存储过程
代码如下
CREATE PROCEDURE [sp_yhb]
@lx VARCHAR(20)='1'
AS
if '1'=@lx
begin
SELECT A.vc_CWUnit, A.vc_Name, A.vc_password, B.vc_sex, B.in_age
FROM dbo.yhb A INNER JOIN
dbo.YHXXB B ON A.in_ID = B.in_yhbid
end
if '2'=@lx
begin
SELECT B.vc_sex, B.in_age
FROM dbo.yhb A INNER JOIN
dbo.YHXXB B ON A.in_ID = B.in_yhbid
end
GO
中间层有ADOStoredProc控件SP_SEARCH,DataSetProvider控件DP,adoconnection控件ADO
连接正常
中间层又方法SEARCH
代码如下
procedure TTEST.SEARCH(const lx, sqltable: WideString);
begin
with SP_SEARCH,Parametersdo
begin
Close;
ProcedureName := sqltable;
Refresh;
Parameters[1].Value :=lx;
OPEN;
end;
// DP.Exported:=TRUE;
end;
客户端调用代码如下
procedure TForm1.BitBtn1Click(Sender: TObject);
var
obj:OleVariant;
begin
obj := CreateOleObject('P_TEST.TEST');
OBJ.SEARCH('2','sp_yhb;1');
// ClientDataSet1.ProviderName:='DP';
ClientDataSet1.Active:=true;
end;
问题是
我调用SEARCH方法传递的LX参数无效
如我在存储过程SP_YHB中不为@LX赋初始值,运行提示未为@lx赋值
如果设置初始值,则只能执行赋了初始值的查询,查询结果正常
请教各位!
数据库中又SP_YHB存储过程
代码如下
CREATE PROCEDURE [sp_yhb]
@lx VARCHAR(20)='1'
AS
if '1'=@lx
begin
SELECT A.vc_CWUnit, A.vc_Name, A.vc_password, B.vc_sex, B.in_age
FROM dbo.yhb A INNER JOIN
dbo.YHXXB B ON A.in_ID = B.in_yhbid
end
if '2'=@lx
begin
SELECT B.vc_sex, B.in_age
FROM dbo.yhb A INNER JOIN
dbo.YHXXB B ON A.in_ID = B.in_yhbid
end
GO
中间层有ADOStoredProc控件SP_SEARCH,DataSetProvider控件DP,adoconnection控件ADO
连接正常
中间层又方法SEARCH
代码如下
procedure TTEST.SEARCH(const lx, sqltable: WideString);
begin
with SP_SEARCH,Parametersdo
begin
Close;
ProcedureName := sqltable;
Refresh;
Parameters[1].Value :=lx;
OPEN;
end;
// DP.Exported:=TRUE;
end;
客户端调用代码如下
procedure TForm1.BitBtn1Click(Sender: TObject);
var
obj:OleVariant;
begin
obj := CreateOleObject('P_TEST.TEST');
OBJ.SEARCH('2','sp_yhb;1');
// ClientDataSet1.ProviderName:='DP';
ClientDataSet1.Active:=true;
end;
问题是
我调用SEARCH方法传递的LX参数无效
如我在存储过程SP_YHB中不为@LX赋初始值,运行提示未为@lx赋值
如果设置初始值,则只能执行赋了初始值的查询,查询结果正常
请教各位!