Session variables into stored proc parameters

Results 1 to 2 of 2

Thread: Session variables into stored proc parameters

  1. #1
    Christin Guest

    Default Session variables into stored proc parameters

    I am trying to put recordset and session variables into a stored procedure (Access Query). I am unsure of the correct syntax:<BR><BR>con.Execute "Exec insertproc " & EmpID, sID<BR> <BR>Or:-<BR>con.Execute "exec Myqueryname (var1,Var2)"<BR><BR>I know the first bits ok &#039;cos I put values in and it worked fine.<BR><BR>I just need to know how to put variables in instead.<BR><BR>Any help with this would be most appreciated. :)

  2. #2
    Katosan Guest

    Default RE: Session variables into stored proc parameters

    I use a command when I do a query<BR>cmd.ActiveConnection = con<BR>&#039; Specify that is a store proc. You must include to have the value of adxxxxxxx constant<BR>cmd.CommandType = adCmdStoredProc<BR>&#039; Specify the name of the store proc<BR>cmd.CommandText = "pTransactionsTous"<BR>&#039; Creation of the parameter. Here I use two parameters. <BR>pVar1" is the name of the param<BR>adInteger is the type<BR>1 is the length<BR>2 is the value to initialize the param<BR>cmd.Parameters.Append cmd.CreateParameter("pVar1", adInteger, adParamInput, 1, 2)<BR>cmd.Parameters.Append cmd.CreateParameter("pVar2", adInteger, adParamInput, 1, false)<BR>&#039; You can create it this way<BR>cmd.Parameters.Append cmd.CreateParameter("pVar1", adInteger, adParamInput, 1)<BR>cmd.Parameters("pVar1") = 0<BR>&#039; Retreive the recordset<BR> cmd, , adOpenStatic, adLockOptimistic<BR>It is long but it work fine<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts