从TSQL存储过程到VB 6的返回值不正确

时间:2013-11-11 07:38:52

标签: sql sql-server tsql vb6

我有一个像这样的SQL存储过程:

CREATE PROCEDURE [dbo].[usp_Test_ListProcessSQL]

@LocationIDs as varchar(max) =''

AS 

BEGIN

    IF EXISTS(SELECT  dbo.Locations.LocationID FROM dbo.Locations where  LocationID in (@LocationIDs))
        Return 0
    ELSE
        Return 1
END

当我像这样运行时:

usp_Test_ListProcessSQL 2478

它返回0

但是当我从VB 6代码运行它时,它返回1

Public Function TestListProcessSQL(lLocationId As String) As Integer
Dim cmd As ADODB.Command, prm As ADODB.Parameter

    Set cmd = New ADODB.Command

    cmd.ActiveConnection = cn
    cmd.CommandType = adCmdStoredProc
    cmd.CommandText = "usp_Test_ListProcessSQL_True"


    With cmd
        .Parameters.Append .CreateParameter("return_value", adInteger, adParamReturnValue)
        .Parameters.Append .CreateParameter("@LocationIDs", adBSTR, adParamInput, , lLocationId)
    End With

    cmd.Execute
    TestListProcessSQL = cmd.Parameters("return_value")

End Function

请说明为什么代码返回错误/不同的值

0 个答案:

没有答案