SqlParameter Class

G

Guest

When I use below code I get "Parameter count does not match Parameter Value
count".

Anyone know why I get this?

SqlParameter[] sqlParameters = new SqlParameter[2];

sqlParameters[0] = new SqlParameter("@NTUserName", SqlDbType.VarChar);
sqlParameters[0].Value = ntUserName;

sqlParameters[1] = new SqlParameter("@FlgActive", SqlDbType.Bit);
sqlParameters[1].Value = 0;

DataSet dsEmployee = null;
dsEmployee =
SqlHelper.ExecuteDataset(Configuration.GetAppConfigSetting("SQLConnect"),
"GetEmployee", sqlParameters);
 
M

Miha Markic [MVP C#]

Perhaps SqlHelper.ExecuteDataset expects more parameters. Or less.
 
M

MSDN

forgot if sqlParameter[x] is zero based or not

Miha Markic said:
Perhaps SqlHelper.ExecuteDataset expects more parameters. Or less.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

C said:
When I use below code I get "Parameter count does not match Parameter
Value
count".

Anyone know why I get this?

SqlParameter[] sqlParameters = new SqlParameter[2];

sqlParameters[0] = new SqlParameter("@NTUserName", SqlDbType.VarChar);
sqlParameters[0].Value = ntUserName;

sqlParameters[1] = new SqlParameter("@FlgActive", SqlDbType.Bit);
sqlParameters[1].Value = 0;

DataSet dsEmployee = null;
dsEmployee =
SqlHelper.ExecuteDataset(Configuration.GetAppConfigSetting("SQLConnect"),
"GetEmployee", sqlParameters);
 
M

MSDN

Forgot if SqlParameter[] sqlParameters = new SqlParameter[x]; is zero
based or not??

where x = 1 or 2 ??

SqlParameter[] sqlParameters = new SqlParameter[1];

Also it should tell you if the number of Parameters are correct for the
Stored procedure "GetEmployee". you are not getting that error.


SA

Miha Markic said:
Perhaps SqlHelper.ExecuteDataset expects more parameters. Or less.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

C said:
When I use below code I get "Parameter count does not match Parameter
Value
count".

Anyone know why I get this?

SqlParameter[] sqlParameters = new SqlParameter[2];

sqlParameters[0] = new SqlParameter("@NTUserName", SqlDbType.VarChar);
sqlParameters[0].Value = ntUserName;

sqlParameters[1] = new SqlParameter("@FlgActive", SqlDbType.Bit);
sqlParameters[1].Value = 0;

DataSet dsEmployee = null;
dsEmployee =
SqlHelper.ExecuteDataset(Configuration.GetAppConfigSetting("SQLConnect"),
"GetEmployee", sqlParameters);
 
M

Miha Markic [MVP C#]

It is zero based.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

MSDN said:
forgot if sqlParameter[x] is zero based or not

Miha Markic said:
Perhaps SqlHelper.ExecuteDataset expects more parameters. Or less.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

C said:
When I use below code I get "Parameter count does not match Parameter
Value
count".

Anyone know why I get this?

SqlParameter[] sqlParameters = new SqlParameter[2];

sqlParameters[0] = new SqlParameter("@NTUserName", SqlDbType.VarChar);
sqlParameters[0].Value = ntUserName;

sqlParameters[1] = new SqlParameter("@FlgActive", SqlDbType.Bit);
sqlParameters[1].Value = 0;

DataSet dsEmployee = null;
dsEmployee =
SqlHelper.ExecuteDataset(Configuration.GetAppConfigSetting("SQLConnect"),
"GetEmployee", sqlParameters);
 
C

Cowboy \(Gregory A. Beamer\)

WHere are you hooking the parameters up to the command object?

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
 
M

Miha Markic [MVP C#]

I was assuming in SqlHelper.ExecuteDataset method call in the last line.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Cowboy (Gregory A. Beamer) said:
WHere are you hooking the parameters up to the command object?

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
C said:
When I use below code I get "Parameter count does not match Parameter
Value
count".

Anyone know why I get this?

SqlParameter[] sqlParameters = new SqlParameter[2];

sqlParameters[0] = new SqlParameter("@NTUserName", SqlDbType.VarChar);
sqlParameters[0].Value = ntUserName;

sqlParameters[1] = new SqlParameter("@FlgActive", SqlDbType.Bit);
sqlParameters[1].Value = 0;

DataSet dsEmployee = null;
dsEmployee =
SqlHelper.ExecuteDataset(Configuration.GetAppConfigSetting("SQLConnect"),
"GetEmployee", sqlParameters);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top