Error: The SqlDbType enumeration value, 4, is invalid.

  • Thread starter Thread starter Ben Fidge
  • Start date Start date
B

Ben Fidge

Hi

I'm getting an error which says "The SqlDbType enumeration value, 4, is
invalid." when calling one of my stored procedures. The SP doesn't actually
take any parameters and my C# code doesn't attempt to pass it any.

SqlDbType value 4 is actually SqlDbType.DateTime.

My SP simply retrieves a list of the most common Shows sold over a period of
the last 31 days

My procedure is as follows:

CREATE PROCEDURE [dbo].[prcTheatres_GetTop5ShowsAsListItem]

as

select UKey, Description as Text from dbo.vwTheatres_Shows where UKey in

(select top 5 UKeyShow from dbo.Theatres_Bookings

inner join dbo.vwTheatres_Shows on dbo.vwTheatres_Shows.UKey =
dbo.Theatres_Bookings.UKeyShow

where Date_Time_Entered > GetDate() - 31 group by UKeyShow order by Count(*)
desc)
 
Also have the following error in our Event Log:

"The SqlDbType enumeration value, 100, is invalid."

When calling the same procedure.

These errors don't appear to be consistent or follow any kind of pattern.

Really confused!!

Ben
 
What sort of result do you get in QA? First glance says to suspect GetDate,
since you are doing mathematical computations on a datetime. Try casting or
converting the date before doing the math.
 
as far as i can see your issue it with the line that states

"where Date_time_entered > getdate() -31"

to go 31 days into the past use the following

where date_time_entered > dateadd(dd,-13,getdate())

Simon

Ben Fidge said:
Also have the following error in our Event Log:

"The SqlDbType enumeration value, 100, is invalid."

When calling the same procedure.

These errors don't appear to be consistent or follow any kind of pattern.

Really confused!!

Ben



Ben Fidge said:
Hi

I'm getting an error which says "The SqlDbType enumeration value, 4, is
invalid." when calling one of my stored procedures. The SP doesn't
actually take any parameters and my C# code doesn't attempt to pass it
any.

SqlDbType value 4 is actually SqlDbType.DateTime.

My SP simply retrieves a list of the most common Shows sold over a period
of the last 31 days

My procedure is as follows:

CREATE PROCEDURE [dbo].[prcTheatres_GetTop5ShowsAsListItem]

as

select UKey, Description as Text from dbo.vwTheatres_Shows where UKey in

(select top 5 UKeyShow from dbo.Theatres_Bookings

inner join dbo.vwTheatres_Shows on dbo.vwTheatres_Shows.UKey =
dbo.Theatres_Bookings.UKeyShow

where Date_Time_Entered > GetDate() - 31 group by UKeyShow order by
Count(*) desc)
 
Back
Top