Question SQL validation defaults to success on sql failure
Last Post 04-08-2010 01:26 PM by Chad Nash. 3 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
JamesCUser is Offline
skipping stones
skipping stones
Posts:14
Avatar

--
03-31-2010 01:42 AM

    While debugging my sql validation on a question, I noticed that if there is an error in the sql validation, then the default is to let the form proceed successfully.

    This is also the way it is documented.

    "The SQL query should return one column called IsValid. If the column returns 0 or False then the validation error message will be thrown, anything else and the user can continue."

    So anything else can for instance be a failure on that validation execution which will let the data be posted.

    IMHO this is the wrong way round. Success should be criteria for user to continue and anything else should generate an error.

    James.

    David ToUser is Offline
    river guide
    river guide
    Posts:2719
    Avatar

    --
    03-31-2010 06:55 AM
    HI, can you post your SQL validation script here?
    If "IsValid" = 0, that means that it will throw the error; if "IsValid" = 1, then it will pass validation. So in your script, if it's valid, return "IsValid" = 1; else return "IsValid" = 0. If you post your script here, I can check it out and get it to work for you since I've done this numerous times before. -- David
    JamesCUser is Offline
    skipping stones
    skipping stones
    Posts:14
    Avatar

    --
    03-31-2010 08:37 PM
    Here is the script. My comment came not as a result of the script, but when my dnn account did not have rights to execute the procedure the validation anyway passed on the form.

    CREATE PROCEDURE [dbo].[IsValidAccountName]

    @AccountName nvarchar(15)
    AS
    BEGIN
    -- Script called by Manu DNN user registration form question event
    -- to see that the account name is valid and available.
    -- JC 26.3.2010

    SET NOCOUNT ON;

    SELECT CASE
    WHEN @AccountName in (Select AccountName From Registrations) THEN 0
    WHEN LEN(@AccountName) < 5 THEN 0
    WHEN @AccountName LIKE '%[^0-9,a-z]%' THEN 0
    ELSE 1
    END
    AS IsValid

    END
    Chad NashUser is Offline
    Posts:5260
    Avatar

    --
    04-08-2010 01:26 PM
    Hi James,

    Thanks for your feedback. Ultimately (either way) the SQL/Stored Procedure should take into account and trap or catch if an error that might occur. I can understand your cause for concern though and will review this for future updates.

    -Chad


    ---
  • film izle
  • 720 izle
  • film
  • sinema izle
  • film makinesi
  • T�rk�e dublaj film
  • film izle
  • film izle
  • baglan film izle
  • sinema izle
  • 1080 film izle
  • film mercegi