간단한 username 출력 프로시저

Posted by Albert 4078Day 15Hour 43Min 2Sec ago [2013-03-19]

프로시저 

=============================================================

CREATE PROCEDURE dbo.getUserName

       @UserID int,

       @UserName varchar(40) output

    as

    set nocount on

    begin

       if @UserID is null return

       select @UserName=username

           from dbo.[userinfo]

           where userid=@UserID

       return

    end

    go


=================================

asp 단

=================================

DIM MyComm,UserID,UserName

    UserID = 1

    Set MyComm = Server.CreateObject("ADODB.Command")

    with MyComm

       .ActiveConnection = MyConStr          'MyConStr는 db연결고리

       .CommandText      = "getUserName"     '프로시저이름

       .CommandType      = 4                 '프로시저 타입임을 알림

       .Prepared         = true              '먼저 sql 실행

       .Parameters.append .CreateParameter("@UserID",3,1,4,UserID)

       .Parameters.append .CreateParameter("@UserName",200,2,40)

       .Execute

    end with

    UserName = MyComm(1)

    Set MyComm = Nothing




LIST

Copyright © 2014 visionboy.me All Right Reserved.