|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SqlParameter ClassWhen 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); Perhaps SqlHelper.ExecuteDataset expects more parameters. Or less.
-- Show quoteMiha Markic [MVP C#] RightHand .NET consulting & development www.rthand.com Blog: http://cs.rthand.com/blogs/blog_with_righthand/ "C" <C@discussions.microsoft.com> wrote in message news:8AC18673-560C-48CF-A1C6-8029A3D03097@microsoft.com... > 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
Show quote "Miha Markic [MVP C#]" <miha at rthand com> wrote in message news:uJAeyJ7bGHA.4932@TK2MSFTNGP03.phx.gbl... > 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" <C@discussions.microsoft.com> wrote in message > news:8AC18673-560C-48CF-A1C6-8029A3D03097@microsoft.com... >> 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.
-- Show quoteMiha Markic [MVP C#] RightHand .NET consulting & development www.rthand.com Blog: http://cs.rthand.com/blogs/blog_with_righthand/ "MSDN" <sql_agent***@hotmail.com> wrote in message news:uYAbFq7bGHA.3344@TK2MSFTNGP03.phx.gbl... > forgot if sqlParameter[x] is zero based or not > > "Miha Markic [MVP C#]" <miha at rthand com> wrote in message > news:uJAeyJ7bGHA.4932@TK2MSFTNGP03.phx.gbl... >> 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" <C@discussions.microsoft.com> wrote in message >> news:8AC18673-560C-48CF-A1C6-8029A3D03097@microsoft.com... >>> 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 Show quote "Miha Markic [MVP C#]" <miha at rthand com> wrote in message news:uJAeyJ7bGHA.4932@TK2MSFTNGP03.phx.gbl... > 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" <C@discussions.microsoft.com> wrote in message > news:8AC18673-560C-48CF-A1C6-8029A3D03097@microsoft.com... >> 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?
-- Show quoteGregory A. Beamer ************************************************* Think Outside the Box! ************************************************* "C" <C@discussions.microsoft.com> wrote in message news:8AC18673-560C-48CF-A1C6-8029A3D03097@microsoft.com... > 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); > I was assuming in SqlHelper.ExecuteDataset method call in the last line.
-- Show quoteMiha Markic [MVP C#] RightHand .NET consulting & development www.rthand.com Blog: http://cs.rthand.com/blogs/blog_with_righthand/ "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@comcast.netNoSpamM> wrote in message news:eoM7V2DcGHA.3484@TK2MSFTNGP03.phx.gbl... > WHere are you hooking the parameters up to the command object? > > -- > Gregory A. Beamer > > ************************************************* > Think Outside the Box! > ************************************************* > "C" <C@discussions.microsoft.com> wrote in message > news:8AC18673-560C-48CF-A1C6-8029A3D03097@microsoft.com... >> 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); >> > > |
|||||||||||||||||||||||