Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

command error,,,

26 views
Skip to first unread message

Julio Gonzalez

unread,
Aug 13, 2003, 11:10:56 PM8/13/03
to
Hi All,

I have the following code in my ASP page. The problem is that when I execute
the command I get an error saying
"Item can not be found in the collection corresponding to the requested name
or ordinal"

What can be the problem?

Thanks in advance

'***************
'Open connectoin
'***************
sub OpenDB

'Instantiate obj vars
set conn = Server.CreateObject("ADODB.Connection")
set comm = Server.CreateObject("ADODB.Command")
set rs = Server.CreateObject("ADODB.Recordset")

'Open DB
'conn.Open "advertisementDB"
conn.Open "Provider=SQLOLEDB;Data Source=ROBERTODELL;Initial
Catalog=AdvertisingDB;User ID=sa"

'Call to help Function on gen_functions.asp
end sub

'***********
'Setup SProc
'***********
sub SetupProcedure(strProcName)

'Setup procedure
comm.ActiveConnection = conn
comm.CommandType = adCmdStoredProc
comm.CommandText = strProcName
comm.Parameters.Refresh

end sub

'********************
'Fill Proc Parameters
'********************
sub FillParameters

'Fill parameters and Execute command

command.Parameters.append
command.Parameters.createparameter("return",adInteger,adParamReturnValue,4)
command.Parameters.append
command.Parameters.createparameter("@UserID",adVarchar,adParamInput,20) =
request.form("edtName")
command.Parameters.append
command.Parameters.createparameter("@Password",adVarchar,adParamInput,30,
request.form("edtPassword"))
command.Parameters.append
command.Parameters.createparameter("@URL",adVarchar,adParamOuput,255, "")

end sub

'*****
'Login
'*****
sub Login
on error resume next

'Fill parameters based in form
FillParameters

'Execute command... be ready to display exceptions generated by DB
comm.Execute

IsValid = comm.Parameters("return")

'If an error happened in DB
if err.Number <> 0 then
DisplayForm
response.Write "<center><br><font color='red'>" & err.Description &
"</font></center>"

'No errors, save session var and redirect
else
if IsValid = 0 then
SaveAndRedirect
else
if IsValid = 1 then
DisplayForm
response.Write "<center><br><font color='red'> Password Invalid. Try
Again. </font></center>"
else
if IsValid = 2 then
response.Write "<center><br><font color='red'> Password has expired.
Contact your administrator. </font></center>"
end if
end if
end if
end if

end sub

Joe Fawcett

unread,
Aug 14, 2003, 7:19:25 AM8/14/03
to
The line where you create @UserId parameter looks wrong. Did you include
adovbs.inc in this page?

--

Joe
"Julio Gonzalez" <jcqu...@hotmail.com> wrote in message
news:edXhpqgY...@TK2MSFTNGP09.phx.gbl...

Bob Barrows

unread,
Aug 14, 2003, 7:38:30 AM8/14/03
to
I've written a utility to generate the CreateParameter statements for you.
It's available at:
http://www.thrasherwebdesign.com/index.asp?pi=links&hp=links.asp&c=&a=clear

HTH,
Bob Barrows
PS. Make sure you have the ado constants defined, either by #including the
adovbs.inc file, or using the technique described here:
http://www.aspfaq.com/show.asp?id=2112

0 new messages