Stored Procedures from ASPs

I want to call a stored procedure with parameters from asp files. My database is on MS SQL 6.5. I am able to call a stored procedure that does not take any parameters, however when I try to call a sp with parameters I get the following error  :

"The parameter object is not defined properly".

Any answers ?
LVL 1
raghuraniAsked:
Who is Participating?
 
TTomConnect With a Mentor Commented:
Raghu:

Actually, I need to post an answer in order for you to grade/award it.  (I and many of the other experts frequently post as comments to encourage discussion and allow a 'complete' answer to be formulated before closing out a question.)

If that is the case, you just need to request an answer from whomever you wish to award points, and they will surely respond.

Thanks,

Tom

P.S.  Time is no problem.  At your convenience. (:-}
0
 
TTomCommented:
Would you post the ASP code which is generating the error?  Generally, there is additional coding required to create the parameters for a stored procedure, and it sounds like this is not being done properly.

Tom
0
 
raghuraniAuthor Commented:
Hi Tom,

Here is what you had asked for.

-------------------------------------------
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual
Studio 6.0">
</HEAD>
<BODY>

<P>&nbsp;</P>

<%
'' Validateuser is a stored Procedure
'' which has two parameters for username & Password
'' If the Stored procedure is executed successfully
'' then "Yes" should be displayed.
''
'set myparam=createobject("ADODB.parameter")
''
set dbcon=server.CreateObject("adodb.connection")
dbcon.ConnectionString="driver={sql

server};database=appls;uid=rajani;pwd=tsa;server=KRISHNA;"
dbcon.Open

set dbcomm = server.CreateObject("ADODB.command")
dbcomm.ActiveConnection="driver={sql

server};database=appls;uid=rajani;pwd=tsa;server=KRISHNA;"

dbcomm.CommandText = "validateuser"
dbcomm.CommandType=adCmdStoredProc
''
set Myfirstparam=dbcomm.CreateParameter(
"Username",adVarChar,adParamInput)
dbcomm.Parameters.Append myFirstparam
''
set

MySecondParam=dbcomm.CreateParameter("Pswrd",adVarChar,adParamInput,8)
dbcomm.Parameters.Append MySecondParam
''
dbcomm.Parameters(1)="AA"
dbcomm.Parameters(2)="BB"
''
dbcomm.Execute

Response.write("yes")
%>

</BODY>
</HTML>
----------------------------------------------------------------
That's it.

Looking forward for your reply.

Bye and thanks,
Raghu.

0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
TTomCommented:
Raghu:

Unfortunately, haven't seen this construction for parameters previously.  However, it seems to me that you have three arguments in one of your definitions and four in the other.

I also think the syntax for your assignment of values for the parameters may be wrong.  I think it should be:

dbcomm.Parameters(1).value="AA"

In fact, for safety's sake, I would probably use:

dbcomm.Parameters("Username").value="AA"

Just some thoughts.

Question:  Does your error message identify the line where the error occurs?  If so, which definition is it?

Tom
0
 
raghuraniAuthor Commented:
Tom,

it is working fine. No problem.
thanks a lot.

PS : I do not know how to select your comment
     as the answer. Give me some time.

regards,
Raghu.

0
 
raghuraniAuthor Commented:
Tom,

your answer was of good help to me.
can you let me know how to use the "in"
and "out" parameters for a stored procedure
with a simple example ?

0
 
TTomCommented:
Raghu:

I assume you are speaking of the Input/Output or Parameter 'Direction' property.  If that is so, I am not really familiar with using the 'out' direction.  The 'in' simply defines the parameter as being supplied to the query.

I would suggest you look up the Visual InterDev mailing list (vi6talk@listbot.com) and pose the question there.  The inhabitants of that list (I lurk a lot) are quite knowledgable and will probably be able to supply better info than I.

Tom
0
All Courses

From novice to tech pro — start learning today.