0

我有一个这样的 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

请建议为什么代码返回错误/不同的值

4

0 回答 0