>Hello All, couldn't decide where best to post this - but here it is, I have a Windows Form with a host of MaskedTextBox controls in it, I have the Mask set to " - - " for "Date" inputting, on completion of data input I call a SQL Server 2000 SP, passing in the "Text" values of the controls as parameters, all is well unless there is no data entered in a control, SQL Server then bombs with "Cannot convert data of type Char to smalldatetime" (not verbatim but near enough!), I've tried checking the parameters in the SP as shown below but no joy
>
>code snippet
>
>PROCEDURE CreateNewClaim(@MasterRef char(10),
> @ClaimRef char (10),
> @BlockAppliedDate varchar(10) = null)
>
>AS
>
>if (len(rtrim(ltrim(@BlockAppliedDate))) = 0 Or @BlockAppliedDate Is null)
> Select @BlockAppliedDate = null
>
>
>I know I could validate it in my calling code , but I prefer to keep all data related processing in the SP, any suggestions appreciated - apols if this thread belongs elsewhere
Pete,
FYI this should probably be in the SQL Server section. SQL Server has an ISDATE() function for just this purpose:
if isdate(@BlockAppliedDate) = 0
Select @BlockAppliedDate = null
Happy coding!