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

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)
 
B

Ben Fidge

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
 
E

Earl

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.
 
S

Simon Whale

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)
 

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

Similar Threads


Top