Hi

I have a web app which is running a report, when I change a parameter under a certain circumstance I get the error message below, I cannot logically work out what is happening, it seems to be falling over outside of my code. If anyone has any information or pointers I would greatly appreciate your help, see error stack belo

Message: The parameter data type of UInt32 is invalid
Source: System.Dat
TargetSite: System.Data.SqlClient.MetaType GetMetaType(System.Object
ErrorType: System.ArgumentExceptio
Parameter: '' was invalid
StackTrace:

-------------------------------------------------------------------------------
at System.Data.SqlClient.MetaType.GetMetaType(Object value)

-------------------------------------------------------------------------------
at System.Data.SqlClient.SqlParameter.SetTypeInfoFromComType(Object value)

-------------------------------------------------------------------------------
at System.Data.SqlClient.SqlParameter.set_Value(Object value)

-------------------------------------------------------------------------------
at System.Data.SqlClient.SqlParameter..ctor(String parameterName, Object value)

-------------------------------------------------------------------------------
at System.Data.SqlClient.SqlParameterCollection.Add(String parameterName, Object value)

Re: Problem with SqlParameterCollection.Add(String parameterName, Object value) by William

William
Wed Apr 28 06:45:45 CDT 2004

What does the parameter declaration look like?
"Neil" <ndglover@urbanscience.com> wrote in message
news:708B9CFC-57C3-4444-BDB0-79EEECD691AF@microsoft.com...
> Hi,
>
> I have a web app which is running a report, when I change a parameter
under a certain circumstance I get the error message below, I cannot
logically work out what is happening, it seems to be falling over outside of
my code. If anyone has any information or pointers I would greatly
appreciate your help, see error stack below
>
> Message: The parameter data type of UInt32 is invalid.
> Source: System.Data
> TargetSite: System.Data.SqlClient.MetaType GetMetaType(System.Object)
> ErrorType: System.ArgumentException
> Parameter: '' was invalid.
> StackTrace:
>
> --------------------------------------------------------------------------
------
> at System.Data.SqlClient.MetaType.GetMetaType(Object value)
>
> --------------------------------------------------------------------------
------
> at System.Data.SqlClient.SqlParameter.SetTypeInfoFromComType(Object value)
>
> --------------------------------------------------------------------------
------
> at System.Data.SqlClient.SqlParameter.set_Value(Object value)
>
> --------------------------------------------------------------------------
------
> at System.Data.SqlClient.SqlParameter..ctor(String parameterName, Object
value)
>
> --------------------------------------------------------------------------
------
> at System.Data.SqlClient.SqlParameterCollection.Add(String parameterName,
Object value)



Re: Problem with SqlParameterCollection.Add(String parameterName, Object value) by Miha

Miha
Wed Apr 28 06:50:15 CDT 2004

Hi Neil,

Can be this the problem?
"Use caution when using this overload of the Add method to specify integer
parameter values. Because this overload takes a value of type Object, you
must convert the integral value to an Object type when the value is zero, as
the following C# example demonstrates.
parameters.Add("@pname", Convert.ToInt32(0));
If you do not perform this conversion, the compiler will assume you are
attempting to call the SqlParameterCollection.Add (string, SqlDbType)
overload."

(from help file)

What is your code, anyway?

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Neil" <ndglover@urbanscience.com> wrote in message
news:708B9CFC-57C3-4444-BDB0-79EEECD691AF@microsoft.com...
> Hi,
>
> I have a web app which is running a report, when I change a parameter
under a certain circumstance I get the error message below, I cannot
logically work out what is happening, it seems to be falling over outside of
my code. If anyone has any information or pointers I would greatly
appreciate your help, see error stack below
>
> Message: The parameter data type of UInt32 is invalid.
> Source: System.Data
> TargetSite: System.Data.SqlClient.MetaType GetMetaType(System.Object)
> ErrorType: System.ArgumentException
> Parameter: '' was invalid.
> StackTrace:
>
> --------------------------------------------------------------------------
------
> at System.Data.SqlClient.MetaType.GetMetaType(Object value)
>
> --------------------------------------------------------------------------
------
> at System.Data.SqlClient.SqlParameter.SetTypeInfoFromComType(Object value)
>
> --------------------------------------------------------------------------
------
> at System.Data.SqlClient.SqlParameter.set_Value(Object value)
>
> --------------------------------------------------------------------------
------
> at System.Data.SqlClient.SqlParameter..ctor(String parameterName, Object
value)
>
> --------------------------------------------------------------------------
------
> at System.Data.SqlClient.SqlParameterCollection.Add(String parameterName,
Object value)



Re: Problem with SqlParameterCollection.Add(String parameterName, Object value) by ndglover

ndglover
Wed Apr 28 07:01:07 CDT 2004

object oValue = dicParameters[ strKey ]

SqlParameter param = parameters.Add( strKey, oValue );

Re: Problem with SqlParameterCollection.Add(String parameterName, Object value) by ndglover

ndglover
Wed Apr 28 07:01:10 CDT 2004

Yeh I read that too but I don't think that is the problem, see my declaration belo

object oValue = dicParameters[ strKey ]
SqlParameter param = parameters.Add( strKey, oValue )

Do you agree?

Re: Problem with SqlParameterCollection.Add(String parameterName, Object value) by Miha

Miha
Wed Apr 28 07:32:10 CDT 2004

What is the type of oValue? (oValue.GetType())
It might be a UInt32 :) which is probably not supported.
Try parameters.Add( strKey, Convert.ToInt32(oValue));

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Neil" <ndglover@urbanscience.com> wrote in message
news:6D3412B9-2653-427B-9A59-E89C11F923C3@microsoft.com...
> Yeh I read that too but I don't think that is the problem, see my
declaration below
>
> object oValue = dicParameters[ strKey ];
> SqlParameter param = parameters.Add( strKey, oValue );
>
> Do you agree?



Re: Problem with SqlParameterCollection.Add(String parameterName, Object value) by William

William
Wed Apr 28 08:27:28 CDT 2004

What is the value of the param... if it's zero, this is the likely problem
http://www.knowdotnet.com/articles/parametergotcha.html

To know for sure, change it to
SqlParameter param = parameters.Add( strKey );
cmd.Parameters[strKey].Value = oValue;

If it's not the problem, then no big deal but if this fixes it, it pretty
much nails it down.

"William Ryan eMVP" <dotnetguru@comcast.nospam.net> wrote in message
news:u$CFQZRLEHA.556@tk2msftngp13.phx.gbl...
> What does the parameter declaration look like?
> "Neil" <ndglover@urbanscience.com> wrote in message
> news:708B9CFC-57C3-4444-BDB0-79EEECD691AF@microsoft.com...
> > Hi,
> >
> > I have a web app which is running a report, when I change a parameter
> under a certain circumstance I get the error message below, I cannot
> logically work out what is happening, it seems to be falling over outside
of
> my code. If anyone has any information or pointers I would greatly
> appreciate your help, see error stack below
> >
> > Message: The parameter data type of UInt32 is invalid.
> > Source: System.Data
> > TargetSite: System.Data.SqlClient.MetaType GetMetaType(System.Object)
> > ErrorType: System.ArgumentException
> > Parameter: '' was invalid.
> > StackTrace:
> >
>
> --------------------------------------------------------------------------
> ------
> > at System.Data.SqlClient.MetaType.GetMetaType(Object value)
> >
>
> --------------------------------------------------------------------------
> ------
> > at System.Data.SqlClient.SqlParameter.SetTypeInfoFromComType(Object
value)
> >
>
> --------------------------------------------------------------------------
> ------
> > at System.Data.SqlClient.SqlParameter.set_Value(Object value)
> >
>
> --------------------------------------------------------------------------
> ------
> > at System.Data.SqlClient.SqlParameter..ctor(String parameterName, Object
> value)
> >
>
> --------------------------------------------------------------------------
> ------
> > at System.Data.SqlClient.SqlParameterCollection.Add(String
parameterName,
> Object value)
>
>