Forums

This topic is locked

Store Procedure error converting the varchar value

Posted 31 Oct 2003 02:32:18
1
has voted
31 Oct 2003 02:32:18 Ben de Groot posted:
I am having a problem is a store procedure that I am using. I dont have much experience with store procedure and the error that i come up with is error;

To give you a bit of background on what I am trying to do, I got the code from;
www.diado.com/articles/recursivenavigation

Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the varchar value '6 3 ' to a column of data type int.

I understand the problem, but I dont understand why it is trying to convert it back in to a interger;

here is my connection;

if(SelectID <> "" then Command1__ID = SelectID

set Command1 = Server.CreateObject("ADODB.Command"
Command1.ActiveConnection = MM_PRODIVEONLINE_STRING
Command1.CommandText = "dbo.sp_GetParentIDs"
Command1.CommandType = 4
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Parameters.Append Command1.CreateParameter("@RETURN_VALUE", 3, 4)
Command1.Parameters.Append Command1.CreateParameter("@ID", 3, 1,4,Command1__ID)
set test = Command1.Execute
test_numRows = 0
ParentIDs = test.Fields.Item("".Value


Here is the store procedure;

CREATE PROCEDURE [dbo].[sp_GetParentIDs]
@ID INT
AS
DECLARE @ParentID INT;
DECLARE @RootIDs VARCHAR(1024);
DECLARE @Path INT;
SET @RootIDs = '';
SET @ParentID = (SELECT ISNULL(ParentID,0) FROM Links WHERE LinkID = @ID);
WHILE @ParentID > 0
BEGIN
SET @RootIDs = @RootIDs + CAST(@ParentID AS VARCHAR(4)) + ','
SET @ParentID = (SELECT ISNULL(ParentID,0) FROM Links WHERE LinkID = @ParentID);
END
IF LEN(@RootIDs) > 0
BEGIN
SET @Path = LEFT(@RootIDs, LEN(@RootIDs) - 1);
END
SELECT @RootIDs ;
GO

Can anyone help, it probably simple!

Ben

Replies

Replied 11 Nov 2003 00:03:41
11 Nov 2003 00:03:41 Phil Shevlin replied:
I would suspect that the problem is that '6 3 ' is not an integer. '63' is.

SelectID is passing the wrong data??

Reply to this topic