ALTER PROCEDURE [dbo].[Qf_LoginRecord] 
@empid   int, 
@EmpCheckCode varchar(50), 
@Ret    int output 
AS 
 set @Ret=1 
BEGIN 
  insert into dbo.Qf_UserAccount (Empid,EmpRant,EmpMobile,EmpCheckCode,CreateTime) 
  select @empid,empRant=cast(rand(binary_checksum(newid()))*3 as int)+1,empmobile=(select mobile from [172.16.1.245].[jxtshare].[dbo].[Ad_Employ] where empid=@empid),@EmpCheckCode,getdate() 
  if @@error=0 
  begin 
  set @Ret=0 
  return 
 end 
END 
有这么一个存储过程 
在asp.net 中调用这个存储过程 
private void loginrecord() 
    { 
        Jxllt.DBUtility.DbHelperSQL.ConnDataBase("jxtmsg", ""); 
        SqlParameter[] list ={ new SqlParameter("@empid", SqlDbType.Int), new SqlParameter("@EmpCheckCode", SqlDbType.VarChar,50), new SqlParameter("@Ret", SqlDbType.Int) }; 
        list[0].Value =Convert.ToInt32(this.txtEmpid.Text); 
        list[1].Value = Hid_code.Value.ToString(); 
        list[2].Direction = ParameterDirection.Output; 
        Jxllt.DBUtility.DbHelperSQL.ExecRunProce("Qf_LoginRecord", list); 
       
    } 
我现在想把ALTER PROCEDURE [dbo].[Qf_LoginRecord] 
@empid   int, 
@EmpCheckCode varchar(50), 
@Ret    int output 
AS 
 set @Ret=1 
BEGIN 
  insert into dbo.Qf_UserAccount (Empid,EmpRant,EmpMobile,EmpCheckCode,CreateTime) 
  select @empid,empRant=cast(rand(binary_checksum(newid()))*3 as int)+1,empmobile=(select mobile from [172.16.1.245].[jxtshare].[dbo].[Ad_Employ] where empid=@empid),@EmpCheckCode,getdate() 
  if @@error=0 
  begin 
  set @Ret=0 
  return 
 end 
END 
有这么一个存储过程 
在asp.net 中调用这个存储过程 
private void loginrecord() 
    { 
        Jxllt.DBUtility.DbHelperSQL.ConnDataBase("jxtmsg", ""); 
        SqlParameter[] list ={ new SqlParameter("@empid", SqlDbType.Int), new SqlParameter("@EmpCheckCode", SqlDbType.VarChar,50), new SqlParameter("@Ret", SqlDbType.Int) }; 
        list[0].Value =Convert.ToInt32(this.txtEmpid.Text); 
        list[1].Value = Hid_code.Value.ToString(); 
        list[2].Direction = ParameterDirection.Output; 
        Jxllt.DBUtility.DbHelperSQL.ExecRunProce("Qf_LoginRecord", list); 
       
    } 
我现在想把empRant的值在这里面取出来,应该怎么做,能不能实实现

解决方案 »

  1.   

    设定 empRant 为输出参数,然后直接获取 list[] 就是你要的数据了
      

  2.   

    --如何将exec执行结果放入变量中?  
    declare   @num   int,   @sql   nvarchar(4000)  
    set   @sql= 'select   @a=count(*)   from   tableName   '  
    exec   sp_executesql   @sql,N '@a   int   output ',@num   output  
    select   @num  
      

  3.   

    打印出来之后然后在asp. net中又怎么把值去出来了
      

  4.   

    你得先会slq怎么返回,sql不会,net就更不行了