How do I call this stored procedure


Author
Message
Thomas Holste
Thomas Holste
StrataFrame User (298 reputation)StrataFrame User (298 reputation)StrataFrame User (298 reputation)StrataFrame User (298 reputation)StrataFrame User (298 reputation)StrataFrame User (298 reputation)StrataFrame User (298 reputation)StrataFrame User (298 reputation)StrataFrame User (298 reputation)
Group: StrataFrame Users
Posts: 144, Visits: 618
Hi there,

I have a stored procedure in my database which works if I use the Management Studio:



USE [GALDATA]

GO

/****** Object: StoredProcedure [dbo].[getfaktposvkzahl] Script Date: 12/05/2013 16:05:32 ******/

SET ANSI_NULLS ON

GO

SET
QUOTED_IDENTIFIER ON

GO

ALTER
PROCEDURE [dbo].[getfaktposvkzahl]

@cISBN char(13),

@cBZNr char(13),

@cDat char(8),

@nVKZahl int Out

AS

BEGIN

SET NOCOUNT OFF;

select @nVKZahl = COUNT(menge) from FAKTPOS inner join FAKTUR

on dbo.FAKTPOS.rgnummer = dbo.faktur.RGNUMMER

where ISTEXT = 0 and rgdatum >= @cDat and (NUMMER = @cISBN or NUMMER = @cBZNr)

END



I call the proc with some value and get a return value which is correct.

When I call this proc in my BO, I always do get a value of 0 although the value must be more.



Public Function getvkzahl(ByVal cISBN As String, ByVal cBZNr As String, ByVal cDat As String) As Integer

Dim loCommand As New SqlCommand("getfaktposvkzahl")

loCommand.CommandType = Data.
CommandType.StoredProcedure

loCommand.Parameters.Add(
"@cISBN", Data.SqlDbType.Char).Direction = Data.ParameterDirection.Input

loCommand.Parameters(
"@cISBN").Value = cISBN

loCommand.Parameters.Add(
"@cBZNr", Data.SqlDbType.Char).Direction = Data.ParameterDirection.Input

loCommand.Parameters(
"@cBZNr").Value = cBZNr

loCommand.Parameters.Add(
"@cDat", Data.SqlDbType.Char).Direction = Data.ParameterDirection.Input

loCommand.Parameters(
"@cDat").Value = cDat

loCommand.Parameters.Add(
"@nVKZahl", Data.SqlDbType.Int).Direction = Data.ParameterDirection.Output

Return CType(ExecuteScalar(loCommand), Int32)

End Fu



Maybe someone could show me, what I am doing wrong.

Thanks in Advance

Thomas
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search