Passing Two paramenters into a query

Results 1 to 2 of 2

Thread: Passing Two paramenters into a query

  1. #1
    Join Date
    Dec 1969

    Default Passing Two paramenters into a query

    How can i pass two parameters (StudentID and CourseID) into a query stored in Access? I am using the following code but obviously it is wrong.<BR><BR>set rsObj3 = connGB.Execute ("qryStudentGradeSelect &#039;" & Cstr(crs) & "&#039; AND &#039;" & Cstr(id) & "&#039;")

  2. #2
    Join Date
    Dec 1969

    Default RE: Passing Two paramenters into a query

    There is a little more to it than what you have. What you are doing is similar, as far as ADO is concerned, to calling a stored procedure. Go here for a complete explanation of how to do it:<BR><BR>;EN-US;Q200190&<BR><BR>However, I will also outline how to do it for your particular case here and the syntax is slightly different, so you can choose whichever works for you:<BR><BR>&#060;!--#include --&#062;<BR>&#060;%<BR>Set rsObj3 = Server.CreateObject("ADODB.RecordSet")<BR>Set Cmd = CreateObject("ADODB.Command") <BR>Cmd.ActiveConnection = connGB<BR>Cmd.CommandText = "qryStudentGradeSelect"<BR>Cmd.CommandType = adCmdStoredProc<BR>Cmd.Parameters.Append Cmd.CreateParameter("crs", adVarChar, adParamInput, 255, Cstr(crs))<BR>Cmd.Parameters.Append Cmd.CreateParameter("id", adInteger, adParamInput, , CLng(id))<BR>Set rsObj3 = Cmd.Execute<BR>%&#062;<BR><BR><BR>Now, you may have a problem with where the "crs" and "id" have been defined. You may have to name those exactly as they are named within the table in the database. And put the @ in front of them. That is how I mormally do it but I also am usually calling an Oracle DB. <BR><BR>Hope this works.<BR>Paul<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