SqlParameter Class

  • Thread starter Thread starter Guest
  • Start date Start date
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);
 
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);
 
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);
 
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);
 
WHere are you hooking the parameters up to the command object?

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
 
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);
 
Back
Top