 |
| SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 23rd, 2003, 09:10 AM
|
|
Registered User
|
|
Join Date: Oct 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
problem with stored procedures
hello i have a problem with stored procedured and asp.
this is my asp page:
dim command
set command = Server.CreateObject("ADODB.Command")
command.ActiveConnection = conn
command.CommandText = "q" 'q is the name of procedure
command.CommandType = adCmdStoredProc
set objParameter = command.CreateParameter ("@codcorso", adVarChar, adParamInput, 10, codcorso)
command.Parameters.Append objParameter
set objParameter = command.CreateParameter ("@inizio", adVarChar, adParamInput, 20, inizio)
command.Parameters.Append objParameter
set objParameter = command.CreateParameter ("@fine", adVarChar, adParamInput, 20, fine)
command.Parameters.Append objParameter
set objParameter = command.CreateParameter ("@sald", adfloat, adParamOutput, , 8)
command.Parameters.Append objParameter
command.Execute
saldato = command.Parameters("@sald")
my procedure is:
CREATE PROCEDURE saldato
(
@codcorso nvarchar(10),
@inizio varchar(20),
@fine varchar(20),
@sald float OUTPUT
)
AS
SELECT SUM(dbo.Luissman_RataEdizione.importo) AS saldato, dbo.Catalogo_TBL_Edizioni.Cod_Corso, dbo.Catalogo_TBL_Corsi.Titolo
FROM dbo.Catalogo_TBL_Corsi INNER JOIN dbo.Catalogo_TBL_Edizioni ON dbo.Catalogo_TBL_Corsi.ID_Corso = dbo.Catalogo_TBL_Edizioni.ID_Corso INNER JOIN dbo.Luissman_RataEdizione ON dbo.Catalogo_TBL_Edizioni.ID_Edizione = dbo.Luissman_RataEdizione.idedizione
WHERE (dbo.Luissman_RataEdizione.saldato = 1) AND (dbo.Luissman_RataEdizione.pagamento_data >= @inizio) AND
(dbo.Luissman_RataEdizione.pagamento_data <= @fine) AND (dbo.Luissman_RataEdizione.emissione = 1) and (dbo.Catalogo_TBL_Edizioni.Cod_Corso =@codcorso)
GROUP BY dbo.Catalogo_TBL_Edizioni.Cod_Corso, dbo.Catalogo_TBL_Corsi.Titolo
GO
BUT THE ASP PAGE RETUR THIS ERROR:
ADODB.Command error '800a0bb9'
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/luissman/CA/CA_VISRICAVI2.asp, line 241
THE LINE 241 IS "command.CommandType = adCmdStoredProc
"
HELP ME PLEASE
THANK'S
|
|

October 23rd, 2003, 09:32 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am not an expert here, but I do notice that @sald is not being set to anything inside the stored procedure. It is not returning anything.
Sal
|
|

October 23rd, 2003, 09:58 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
|
|
I see a few suspicious things:
1. The command object's commandtext property is assigned the value "q", yet the stored procedure's name is given as 'saldato'.
2. Are you sure you have defined the value of 'adCmdStoredProc' properly? (It should be &H0004). Do you have all the other constants defined properly? (e.g. 'adVarChar, etc)
3. The stored proc defines its first parameter as nvarchar(10), yet your setup of the parameter gives it as adVarChar.
4. The output parameter is never given a value in the stored proc.
5. Since your stored procedure returns a recordset, the output parameter should not be retrieved until after the recordset has been completely read.
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
|
|

October 23rd, 2003, 10:18 AM
|
|
Registered User
|
|
Join Date: Oct 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thank's but i forgot in my topic to write a line that there's in my asp page:
dim q
q="saldato"
and i correct in my setup parameter advarchar in adNVarchar.
my new stored procedure is :
CREATE PROCEDURE saldato
(
@codcorso nvarchar(10),
@inizio varchar(20),
@fine varchar(20),
@sald float(8) OUTPUT
)
AS
SELECT SUM(dbo.Luissman_RataEdizione.importo) AS saldato, dbo.Catalogo_TBL_Edizioni.Cod_Corso, dbo.Catalogo_TBL_Corsi.Titolo
FROM dbo.Catalogo_TBL_Corsi INNER JOIN dbo.Catalogo_TBL_Edizioni ON
dbo.Catalogo_TBL_Corsi.ID_Corso = dbo.Catalogo_TBL_Edizioni.ID_Corso INNER JOIN dbo.Luissman_RataEdizione ON dbo.Catalogo_TBL_Edizioni.ID_Edizione = dbo.Luissman_RataEdizione.idedizione
WHERE (dbo.Luissman_RataEdizione.saldato = 1) AND (dbo.Luissman_RataEdizione.pagamento_data >= @inizio) AND
(dbo.Luissman_RataEdizione.pagamento_data <= @fine) AND (dbo.Luissman_RataEdizione.emissione = 1) and (dbo.Catalogo_TBL_Edizioni.Cod_Corso =@codcorso)
GROUP BY dbo.Catalogo_TBL_Edizioni.Cod_Corso, dbo.Catalogo_TBL_Corsi.Titolo
GO
but i have again error!!!
|
|

October 23rd, 2003, 10:49 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
|
|
The code you posted shows:
command.CommandText = "q" 'q is the name of procedure
which indicates the stored procedure name is the string "q", not the contents of the variable 'q'.
Also - read the rest of my earlier post regarding the correct values for the variaous ADO constants...
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
|
|

October 23rd, 2003, 11:21 AM
|
|
Registered User
|
|
Join Date: Oct 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i don't find your post regarding the correct values for the variaous ADO constants, but i find another ADO constants list,but there isn't float!!!!
|
|

October 23rd, 2003, 11:37 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I guess you could use one of the following:
Const adSingle = 4
Const adDouble = 5
|
|

October 23rd, 2003, 12:36 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Quote:
quote:Originally posted by robyd
i don't find your post regarding the correct values for the variaous ADO constants, but i find another ADO constants list,but there isn't float!!!!
|
My earlier post in this thread said:
Quote:
quote:
2. Are you sure you have defined the value of 'adCmdStoredProc' properly? (It should be &H0004). Do you have all the other constants defined properly? (e.g. 'adVarChar, etc)
|
Have you properly defined these ADO constants in your web page(s)? Remember that if you do not define a variable in an ASP page, it takes on the value NULL or empty. If you reference a named constant like 'adCmdStoredProc' without ever defining it, VBscript thinks it's a variable and assigns a null value to it. If you do not provide a value for 'adCmdStoredProc', or if you have given it the wrong value, that may result in the error you are experiencing.
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
|
|
 |