Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2005
    Posts
    1

    Question Unanswered: Problem calling an SQL SP in ASP!!

    Hello there, I hope someone can help me. I'm fairly new to ASP but not to SQL. I've written a few programs using functions in ASP but I now want to use stored procedures as things have gotten more complicated. i was doing fine until reached some stupid error saying.
    "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."

    My code is
    <%
    Set cn = Server.CreateObject("ADODB.Connection")
    cn.Open "Provider=SQLOLEDB.1;Initial Catalog=issue;Integrated Security=SSPI;Data Source=localhost"
    Set cmd = Server.CreateObject("ADODB.Command")
    Set cmd.ActiveConnection = cn
    cmd.CommandText = "dbo.sp_add_issue"
    cmd.CommandType = adCmdStoredProc
    cmd.Parameters.Append cmd.CreateParameter("Param1", adInteger, adParamInput)
    cmd("iStatus") = 22
    cmd.Execute
    %>
    The problematic line is setting the command type. Is my connection script in error?

  2. #2
    Join Date
    Nov 2004
    Posts
    285
    Provided Answers: 1
    Well the way I normally execute a SP is to do quite simple.

    After opening the connection to SQL I just execute the SP not settin gup any sort of command.

    Code:
    cn.Open
    
    cn.Execute "Execute StoredProcedure, parameter1, parameter2"
    I know it is a very simple way but it works like a charm, never had a problem with this and been used for a good few years now.

  3. #3
    Join Date
    May 2004
    Posts
    125
    Quote Originally Posted by robomule
    Hello there, I hope someone can help me. I'm fairly new to ASP but not to SQL. I've written a few programs using functions in ASP but I now want to use stored procedures as things have gotten more complicated. i was doing fine until reached some stupid error saying.
    "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."

    My code is
    <%
    Set cn = Server.CreateObject("ADODB.Connection")
    cn.Open "Provider=SQLOLEDB.1;Initial Catalog=issue;Integrated Security=SSPI;Data Source=localhost"
    Set cmd = Server.CreateObject("ADODB.Command")
    Set cmd.ActiveConnection = cn
    cmd.CommandText = "dbo.sp_add_issue"
    cmd.CommandType = adCmdStoredProc
    cmd.Parameters.Append cmd.CreateParameter("Param1", adInteger, adParamInput)
    cmd("iStatus") = 22
    cmd.Execute
    %>
    The problematic line is setting the command type. Is my connection script in error?
    Are you including the file adovbs.inc? Without that, ASP does not know the values of the constants like adinteger.

  4. #4
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    I'm not really sure what you are doing here, but shouldn't
    Code:
    cmd.Parameters.Append cmd.CreateParameter("Param1", adInteger, adParamInput)
    cmd("iStatus") = 22
    be
    Code:
    cmd.Parameters.Append cmd.CreateParameter("Param1", adInteger, adParamInput)
    cmd("Param1") = 22
    ??

    I normally apply the values to my parameters when I create them though so....

Posting Permissions

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