Hi folks,
I have a SQL Server 2008 database and want to access a table from a C#-WCF via a stored procedure. The proc is a simple SELECT query that gets the row of a given id and fills the result into some outputparameters:
PROCEDURE [dbo].[get_stammInfo]
-- Add the parameters for the stored procedure here
@id int,
@strassenSchluessel int OUTPUT,
@hausNummer int OUTPUT,
@zusatz nvarchar(1) OUTPUT,
...
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT @strassenSchluessel = strassenSchluessel,
@hausNummer = hausNummer,
@zusatz = zusatz,
...
FROM gebaeudeStamm
WHERE id = @id
END
In my C#-Code, I create a commandobject, connect with the database and add the parameters to the commandobject.
When I call the ExecuteNonQuery, it throws the following exception
{"Die Prozedur oder Funktion 'getstammInfo' erwartet den '@id'-Parameter, der nicht bereitgestellt wurde."} which translate to something like "The procedure or function 'getstammInfo' expects the ' @id'-Parameter, which isn't provided"
Problem sounds clear, but actually I provided the id parameter. I can query it in the directwindow of VS2008:
_command.Parameters[0]
{@id}
base {System.Data.Common.DbParameter}: {@id}
CompareInfo: None
DbType: Int32
Direction: Input
IsNullable: false
LocaleId: 0
Offset: 0
ParameterName: "@id"
Precision: 0
Scale: 0
Size: 0
SourceColumn: ""
SourceColumnNullMapping: false
SourceVersion: Current
SqlDbType: Int
SqlValue: {7112}
TypeName: ""
UdtTypeName: ""
Value: 7112
XmlSchemaCollectionDatabase: ""
XmlSchemaCollectionName: ""
XmlSchemaCollectionOwningSchema: ""
As you can see, the id Parameter exists in the Parameterscollection and it has the same type like the parameter, the stored proc expects. I have no idea, what might be wrong, but it seems that the errormessage is wrong and some other error occured ...
Can anyone here hint me at what I should look to find the error?