select @userpsw=encrypt(@userpsw)  --encrypt是什麼東東?

解决方案 »

  1.   

    並且truepassword
    是這個過程的傳入值.
    和return的值沒有關係.
      

  2.   

    encrypt()是一个sql的加密函数。
    我以为truepassword是返回值。我不能用set truepassword=conn.execute(...)语句来获得返回值啊。
    fstruserid和fstrUserPassword是传入的参数。
      

  3.   

    哦,是這樣.
    那麼修改一下.CREATE PROCEDURE sp_psw
    (@UserId [varchar](15),
    @UserPsW [varchar](20),
    @truepassword int out )
    AS
    declare @oldpsw varchar(20)
    select @oldpsw=userpassword from tpeople where userid=@UserId
    select @UserPsW=encrypt(@UserPsW)
    if @oldpsw=@UserPsW 
    set @truepassword = 1
    else
    set @truepassword = 2
    return @truepassword
    調用程序為:
    set conn= server.CreateObject("ADODB.CONNECTION")
    conn.Open Application("system_ConnectionString")  ‘包含存储过程的数据库strsql="sp_psword '"&fstruserid&"','"&fstrUserPassword&"',&truepassword&"
    call conn.Execute (strsql)然後看看truepassword這個值是不是你想要的.
      

  4.   

    报错说返回的truepassword是个未初始化的值
      

  5.   

    我赋值为9了,可是返回的值总是9,应该不是1就是2啊?
    我把程序改成这样试也不成。
    CREATE PROCEDURE sp_psw
    @UserId [varchar](15),
    @UserPsW [varchar](20),
    @truepassword int output
    AS
    declare @oldpsw varchar(20)
    select @oldpsw=userpassword from tpeople where userid=@UserId
    select @UserPsW=encrypt(@UserPsW)
    if @oldpsw=@UserPsW 
    return 1
    else
    return 2
    为什么,为什么?他欺负我是新手!!!我哭哭哭.....我怎么一不留神就做了程序员呢,我是白痴。
      

  6.   

    我怎么能在存储过程中进行调试呢?书上说可以用print语句,可是他打印到哪里去了,我在哪里才能看到我打印的语句呢??
      

  7.   

    將你的程序修改成這樣:CREATE PROCEDURE sp_psw
    (@UserId [varchar](15),
    @UserPsW [varchar](20),
    @truepassword int out )
    AS
    declare @oldpsw varchar(20)
    select @oldpsw=userpassword from tpeople where userid=@UserId
    print(@oldpsw)
    select @UserPsW=encrypt(@UserPsW)
    print(@UserPsW)
    if @oldpsw=@UserPsW 
    set @truepassword = 1
    else
    set @truepassword = 2
    return @truepassword
      

  8.   

    --然後在SQL Server的Query Analyzer中這樣執行:
    declare @nprint int
    set @nprint = 0
    exec sp_psw 'aaa','bbb',@nprint  --其中'aaa','bbb'為你具體的值
    print @nprint
      

  9.   

    给一段用VBScript调用存储过程的的代码,希望有启示。
        Dim lComStat As Command
        Set lComStat = CreateObject("adodb.command")
        lComStat.ActiveConnection = gConnGeneral
        lComStat.CommandType = adCmdStoredProc
        lComStat.CommandText = "存储过程名"
        lComStat.Parameters(1) = 参数1
        lComStat.Parameters(2) = 参数2
        
        lComStat.Execute
        
        If lComStat.Parameters(0) < 0 Then ‘lComStat.Parameters(0)为返回值
            MsgBox "数据入库错误,请与系统生产商取得联系!", vbOKOnly, "信息提示!"
            Exit Sub
        End If
      

  10.   

    这样调用存储过程后Parameters(0)保存的都是返回值,除非你有特殊设置。
    一般情况下返回值为0表示存储过程执行正确,否则有问题。
    当然你也可以自己定义返回值,象上面那样。
      

  11.   

    你根本就不明白什么是输出参数,什么是存储过程的返回值:
    @truepassword int out 是一个输出参数,它可以是任何SQL的数据类型。
    return 1设置一个存储过程的返回值,只能返回一个整数,注意-1到-99为系统返回值。在ASP中读取输出参数和返回值是不同的:
    1。读取输出参数
    cmd.Parameters.Append cmd.Parameters.CreateOarameter("truepassword",adInteger,adParamOutput) '其中的truepassword必须与存储过程中的out参数一致
    ......
    cmd.execute
    response.write cmd("truepassword") '显示输出参数2.读取存储过程返回值
    注意:在读取存储过程返回值以前,你必须关闭含有数据行的recordsetcmd.Parameters.Append cmd.Parameters.CreateOarameter("truepassword",adInteger,adParamReturnValue) 'truepassword是任意的名称
    ......
    set rs=cmd.execute
    ......
    rs.close '必须的
    response.write cmd("truepassword")
      

  12.   

    好高深啊,@+@ 晕菜,不过我试了阿刚的程序,虽然语法上有所不同,但是还是很好使的,总算返回了我要的值。lComStat.Parameters(0)这个值是输出参数吗?不是返回值?我看的书上只有提返回值。谢谢各位大哥小弟,我总算看到了工作的一点曙光。三位我都想给分,不太好分啊。
      

  13.   

    hydnoahark(诺亚方舟)是說我嗎?to lly223(霏雨):
    在Query Analyzer中這樣執行:
    declare @nprint int
    set @nprint = 0
    exec sp_psw 'aaa','bbb',@nprint output --其中'aaa','bbb'為你具體的值
    print @nprint