Re: SQL stored procedure not working.
From: Lin Ma (a_at_a.com)
Date: 03/23/04
- Next message: Laphan: "Re: Asp & MySQL Tips"
- Previous message: Neil Smith [MVP Digital Media]: "Re: Microsoft Project 2003 xml and ASP App."
- In reply to: Bob Barrows [MVP]: "Re: SQL stored procedure not working."
- Next in thread: Bob Barrows [MVP]: "Re: SQL stored procedure not working."
- Reply: Bob Barrows [MVP]: "Re: SQL stored procedure not working."
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 23 Mar 2004 13:55:38 -0600
Thanks Bob, It is working.
One more question: I use AddOpenKeySet to get the recountcount. Like:
rs.open strSQL, strConn, AdOpenKeySet
Then I use (Response.Write rs.recordcount) to display the total record from
the query.
If I do not use that, how can I get the total record count? Do I need
something in the stored procedure?
Thanks,
Lin
"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:%23Uz4zhQEEHA.2088@TK2MSFTNGP10.phx.gbl...
> Lin Ma wrote:
> > I create a stored procedure and a asp page. But I got an error.
> > Please help.
> >
> > Thanks,
> >
> > Lin
> >
> > Error Type:
> > Microsoft OLE DB Provider for SQL Server (0x80040E10)
> > Procedure 'getCustomerList' expects parameter '@Location', which was
> > not supplied.
> >
> > --------------- asp page --------------
> > Dim cmd, ln
> >
> > Set cmd = Server.CreateObject("ADODB.Command")
> > With cmd
> > .ActiveConnection = strCustomerCon
> > .commandText = "getCustomerList"
> > .CommandType = adCmdStoredProc
>
> The first parameter you should be creating is the Return parameter:
> .Parameters.Append .CreateParameter ("RETURN_VALUE", _
> adInteger, adParamReturnValue)
>
> > .Parameters.Append .CreateParameter ("@Location", adVarChar,
> > adParamInput, 25)
> > .Parameters("@Location") = "TX1"
> > .Execute ln, , adOpenKeySet
>
> There are several problems here:
> 1. You aren't supplying a recordset variable to receive the resultset
> returned from this stored procedure. This is all that you need:
>
> Set rs= .Execute
>
> 2. You cannot specify the cursor type via the third argument in the
Execute
> method. That argument is for CommandType (which you've already set) and
> ExecuteOption arguments.
> 3. Even if you could specify the cursor type there, you probably should
not
> be attempting to open an expensive keyset cursor. It is very rare in asp
> that you will have a cursor open long enough to care about changes made by
> other users (which is the only reason to use a keyset cursor).
>
> > End with
> >
> > ------------------- Stored procedure --------------
> > CREATE PROCEDURE [dbo].[getCustomerList]
> > (
> > @Location nvarchar(25)
> > )
> > AS
> > Select * from Customer where Location = @Location order by
> > CustomerName
> > GO
>
> Since your procedure has no output parameters, and you don't seem to be
> interested in the RETURN value, you do not need to use a Command object.
You
> can simply say this:
>
> set cn=createobject("adodb.connection")
> cn.open strCustomerCon
> Set rs=createobject("adodb.recordset")
> cn.getCustomerList "TX1", rs
>
> If you are determined to use the Command object, you might want to try my
> stored procedure code generator which is available here:
> http://www.thrasherwebdesign.com/index.asp?pi=links&hp=links.asp
>
> HTH,
> Bob Barrows
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>
- Next message: Laphan: "Re: Asp & MySQL Tips"
- Previous message: Neil Smith [MVP Digital Media]: "Re: Microsoft Project 2003 xml and ASP App."
- In reply to: Bob Barrows [MVP]: "Re: SQL stored procedure not working."
- Next in thread: Bob Barrows [MVP]: "Re: SQL stored procedure not working."
- Reply: Bob Barrows [MVP]: "Re: SQL stored procedure not working."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|