Using ADODB.Command

Results 1 to 2 of 2

Thread: Using ADODB.Command

  1. #1
    Join Date
    Dec 1969

    Default Using ADODB.Command

    I&#039;m trying to pass some input parameters to a stored proc using the ADODB.Command object and I&#039;m getting the error "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another." I&#039;ve gone through it several times and just don&#039;t see the error. Thanks.<BR><BR>&#060;%<BR><BR>strTicker = Request.Form("Ticker")<BR>strCompanyName = Request.Form("CompanyName")<BR>strIndustry = Request.Form("Industry")<BR><BR>&#039;Create our connection (SQL Server OLEDB Connection)<BR> Set con=Server.Createobject("ADODB.Connection")<BR> con.ConnectionString = "Provider=SQLOLEDB; Data Source=192.168.x.x; Initial Catalog=Mydatabase; User ID=WebUser; Password=x" <BR> con.Open<BR><BR>&#039; Create Command object we&#039;ll use to execute the SP<BR>Set cmdStoredProc = Server.CreateObject("ADODB.Command")<BR><BR>&#039; Set our Command to use our existing connection<BR>Set cmdStoredProc.ActiveConnection = con<BR><BR>&#039; Set the SP&#039;s name and tell the Command object<BR>&#039; that the name we give is supposed to be a SP<BR>cmdStoredProc.CommandText = "sp_DynamicSQL"<BR>cmdStoredProc.CommandType = adCmdStoredProc<BR><BR>&#039; Create and add the SP&#039;s required parameter to our<BR>&#039; Command object. The SP<BR>&#039; passes back a full recordset.<BR><BR>Set Ticker = cmdStoredProc.CreateParameter("@Ticker", adParamInput)<BR>Ticker.Value = "IBM"<BR>cmdStoredProc.Parameters.Append Ticker<BR><BR>Set CompanyName = cmdStoredProc.CreateParameter("@CompanyName", adParamInput)<BR>CompanyName.Value = strCompanyName<BR>cmdStoredProc.Parameters.Append CompanyName<BR><BR>Set Industry = cmdStoredProc.CreateParameter("@Industry", adParamInput)<BR>Industry.Value = strIndustry<BR>cmdStoredProc.Parameters.Append Industry<BR><BR><BR>&#039; Run the SP by executing the command and grab<BR>&#039; the returned recordset.<BR>Set rstStoredProc = cmdStoredProc.Execute<BR><BR>&#039; Spit out our data which I pull out of the recordset.<BR>Response.Write Trim(rstStoredProc.Fields("Ticker"))<BR>Response.W rite " "<BR>Response.Write Trim(rstStoredProc.Fields("CompanyName"))<BR>Respo nse.Write " "<BR>Response.Write Trim(rstStoredProc.Fields("Industry"))<BR>Response .Write " "<BR><BR><BR>&#039; Kill our objects<BR>Set rstStoredProc = Nothing<BR>Set cmdStoredProc = Nothing<BR><BR>&#039; Close and kill our connection<BR>con.Close<BR>Set con = Nothing<BR>

  2. #2
    Join Date
    Dec 1969

    Default And you omit the important part!

    Two in a row.<BR><BR>WHAT LINE do you get the error from??????<BR><BR>But in your case, I&#039;m going to bet that your answer is in the ASPFAQs. Click on the link (above center) to the ASPFAQs.<BR><BR>Then choose the category "Databases, Errors". And see your FAQ there, I betcha.<BR><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