error Microsoft SQL Native Client (0x80040E14) in asp

  • Hi i'm developing a web application in asp with sql server. My problem is that when i want to pass the data from a form and it has any spaces in the data, for example "John Smith" it tells me this:

    Microsoft SQL Native Client (0x80040E14)

    Incorrect syntaxis near 'Smith'

    But if i put "JohnSmith" it has no errors, how could i fix it??? thanks!!!!!!!!

  • Hopefully this will clarify the problem:

    USE tempdb;

    go

    CREATE PROCEDURE dbo.sp_test ( @val VARCHAR(50) ) AS PRINT 'OK: ' + @val;

    go

    EXEC dbo.sp_test JohnSmith;

    go

    EXEC dbo.sp_test John Smith;

    go

    EXEC dbo.sp_test 'John Smith';

    go

    So, use quotes. But remember to escape a quote, eg:

    DECLARE @val VARCHAR(50);

    SET @val = 'Rock-''n-Roll';

    SET @val = Replace( @val, '''', '''''' ); --> Escape '

    EXEC dbo.sp_test @val;

  • Yes it was all about hte quotes!! THANKS!!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply