본문 바로가기

ASP,MSSQL Tip

[ASP] asp 저장 프로시져 사용법

반응형

<== 시간 나시면 공지사항 한번 읽어 주세요.


  '디비 접속
    DB_Connect

    Dim gCMD As New ADODB.Command
    Set gCMD.ActiveConnection = AdoCon '<--- 님 프로그램에서 사용하는 ADOConnection 변수
    Set rs = New ADODB.Recordset
   
    With gCMD
        .CommandType = adCmdStoredProc
        .Prepared = True
        .CommandTimeout = 15  '<--- Timeout 시간지정
        .CommandText = "proc_test"    '<--- 프로시저 이름
        .CommandType = adCmdStoredProc
        .Parameters.Refresh
        .Parameters("@buy_Co").Value = "idtong" ' <--- IN 파라메터 이름
       
        Set rs = gCMD.Execute
        num = .Parameters("@cnt").Value      '  <--- OUT 파라메터 이름
    End With
   
    If IsNull(num) = True Then
            num = 0
    End If
   
    MsgBox num
    MsgBox rs(0)

반응형