SQL Procedure
CREATE PROCEDURE xxx.test
@p1 int
AS
BEGIN
SET NOCOUNT ON;
SELECT @p1
END
C# source
using(OdbcConnection Connection=new OdbcConnection("Driver={SQL Native client};SERVER=###;DATABASE=###;Trusted_Connection=yes;"))
{
Connection.Open();
using(OdbcTransaction Trans=Connection.BeginTransaction())
{
using(OdbcCommand Command=Connection.CreateCommand())
{
try
{
Command.CommandType = System.Data.CommandType.StoredProcedure;
Command.CommandText = "xxx.test";
Command.Transaction = Trans;
OdbcParameter param=new OdbcParameter("@p1",OdbcType.Int);
param.Value = 1;
Command.Parameters.Add(param);
Command.ExecuteNonQuery();
}
catch (OdbcException OdbcException)
{
Console.Write(OdbcException.Message);
}
}
Trans.Rollback();
}
Connection.Close();
}
I always get exception saying ERROR [42000] [Microsoft][SQL Native Client][SQL Server]Procedure or function 'test' expects parameter '@p1', which was not supplied."
However when i debug, put breakpoint on line ExecuteNonQuery and click through Command.Parameters until I see items I can see that this parameter is definitely there and its value is set, type is correct - see http://s29.postimg.org/5cqvo7iqv/Visicom_Windows.png (i don't have enough of reputation yet)
what am i doing wrong?