If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Problem calling an SQL SP in ASP!!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-09-05, 19:01
robomule robomule is offline
Registered User
 
Join Date: Mar 2005
Posts: 1
Question 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?
Reply With Quote
  #2 (permalink)  
Old 03-10-05, 03:04
plsh plsh is offline
Registered User
 
Join Date: Nov 2004
Posts: 253
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.
Reply With Quote
  #3 (permalink)  
Old 03-10-05, 09:11
DMWCincy DMWCincy is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 03-10-05, 17:01
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
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....
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On