ParameterCheck 2

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for universal data access
Post Reply
mlagasio
Posts: 43
Joined: Mon 14 Mar 2011 13:42

ParameterCheck 2

Post by mlagasio » Thu 05 May 2011 11:29

Hi

with the following piece of code

UniConnection conn = new UniConnection(cs.ConnectionString);

UniCommand cmd = new UniCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
//cmd.ParameterCheck = true;
cmd.CommandText = "MyStoredProcedure";

UniParameter par1 = new UniParameter("@v_Parameter", UniDbType.VarChar, 50);
par1.Value = ParameterName;
cmd.Parameters.Add(par1);


UniParameter par2 = new UniParameter("@v_Area", UniDbType.VarChar, 50);
par2.Value = Area;
cmd.Parameters.Add(par2);

UniParameter par3 = new UniParameter("@v_Profile", UniDbType.VarChar, 50);
par3.Value = Profile;
cmd.Parameters.Add(par3);

UniParameter par4 = new UniParameter("@v_ACTIVATED", UniDbType.Int);
par4.Direction = ParameterDirection.Output;
cmd.Parameters.Add(par4);


UniParameter par5 = new UniParameter("@v_ConfigValue", UniDbType.VarChar, 261);
par5.Direction = ParameterDirection.Output;
cmd.Parameters.Add(par5);

UniParameter par6 = new UniParameter("@v_ConfigMin", UniDbType.VarChar, 50);
par6.Direction = ParameterDirection.Output;
cmd.Parameters.Add(par6);

UniParameter par7 = new UniParameter("@v_ConfigMax", UniDbType.VarChar, 50);
par7.Direction = ParameterDirection.Output;
cmd.Parameters.Add(par7);


conn.Open();
cmd.ExecuteNonQuery();

Activated = (int)cmd.Parameters["v_Activated"].Value;

all runs fine; if I decomment cmd.ParameterCheck = true, I've a problem on instruction

cmd.ExecuteNonQuery();

the connection in this case is to SQL Server and the error is

"Procedure or Function 'MyStoredProcedure' expects parameter '@v_ACTIVATED', which was not supplied."

The error vanish if I put a default to OUTOUT parameters (in the stored procedure)


The scripts for the stored procedure and the table it uses are

CREATE PROCEDURE MyStoredProcedure
@v_PARAMETER VARCHAR(50) ,

@v_AREA VARCHAR(50) ,
@v_PROFILE VARCHAR(50) ,
@v_ACTIVATED INT OUTPUT,
@v_ConfigValue VARCHAR(261) OUTPUT ,
@v_ConfigMin VARCHAR(50) OUTPUT,
@v_ConfigMax VARCHAR(50) OUTPUT

-- @v_ACTIVATED INT = 0 OUTPUT,
-- @v_ConfigValue VARCHAR(261) = null OUTPUT ,
-- @v_ConfigMin VARCHAR(50) = null OUTPUT,
-- @v_ConfigMax VARCHAR(50) = null OUTPUT

AS
BEGIN

SET @v_ACTIVATED = 0
SET @v_ConfigValue = NULL
SET @v_ConfigMin = null
SET @v_ConfigMax = null

SELECT @v_ACTIVATED = Activated, @v_ConfigValue = ConfigValue, @v_ConfigMin = ConfigMin, @v_ConfigMax = ConfigMax
FROM ConfigParam
WHERE Parameter = @v_PARAMETER AND Area = @v_area AND [Profile] = @v_profile;


END


CREATE TABLE ConfigParam(
[Parameter] [varchar](50) NOT NULL,
[Area] [varchar](50) NOT NULL,
[Profile] [varchar](50) NOT NULL,
[Activated] [int] NOT NULL,
[ConfigValue] [varchar](261) NULL,
[ConfigMin] [varchar](50) NULL,
[ConfigMax] [varchar](50) NULL,
CONSTRAINT [PK_ConfigParam] PRIMARY KEY CLUSTERED
(
[Parameter] ASC,
[VirtualHostSetID] ASC,
[Area] ASC,
[Profile] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]


In SQL Server parameter marked as OUTPUT are also input param, but in c# code I've marked parameter.direction as Output!

Best Regards

Marco

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 10 May 2011 16:09

Thank you for your report. We have reproduced the described behaviour. We will investigate it and notify you about the results as soon as possible.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 13 May 2011 14:14

The bug with the UniCommand.ParameterCheck property is fixed. I will post here when the corresponding build of dotConnect Universal is available for download.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 19 May 2011 10:48

New build of dotConnect Universal 3.20.50 is available for download now!
It can be downloaded from http://www.devart.com/dotconnect/univer ... nload.html (trial version) or from Registered Users' Area (for users with valid subscription only): http://secure.devart.com/ .

For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=21035 .

Post Reply