Prepare和连接字符串都没问题,我都把值打印出来了。存储过程为: CREATE PROCEDURE proclogin (@user_id varchar (30), @password varchar(30) ,@flag varchar(2)) AS declare @tmpcount1 int declare @tmpcount2 int declare @tmpcount3 int select @tmpcount1=count(*) from admin where username=@user_id and password=@password select @tmpcount2=count(*) from user_info where UserName=@user_id and UserPassword=@password select @tmpcount3=count(*) from company_info where account_id=@user_id and account_pwd=@password if @tmpcount1>0 set @flag='1' else begin if @tmpcount3>0 and @tmpcount2>0 set @flag='11' if @tmpcount3>0 and @tmpcount2<1 set @flag='10' if @tmpcount3<1 and @tmpcount2>0 set @flag='01' if @tmpcount3<1 and @tmpcount2<1 set @flag='00' end GO
CREATE PROCEDURE proclogin
(@user_id varchar (30), @password varchar(30) ,@flag varchar(2))
AS
declare @tmpcount1 int
declare @tmpcount2 int
declare @tmpcount3 int
select @tmpcount1=count(*) from admin where username=@user_id and password=@password
select @tmpcount2=count(*) from user_info where UserName=@user_id and UserPassword=@password
select @tmpcount3=count(*) from company_info where account_id=@user_id and account_pwd=@password
if @tmpcount1>0
set @flag='1'
else
begin
if @tmpcount3>0 and @tmpcount2>0
set @flag='11'
if @tmpcount3>0 and @tmpcount2<1
set @flag='10'
if @tmpcount3<1 and @tmpcount2>0
set @flag='01'
if @tmpcount3<1 and @tmpcount2<1
set @flag='00'
end
GO