JohnnyLong
Programmer
Hi, I'm having real problems running a stored proc with a string passed from vb.net. In query analyzer I can successfully run the following dynamic sql query:
DECLARE @pSearch1 as varchar(500), @pSearch2 as varchar(500), @pSearch3 as varchar(500)
SET @pSearch1 = 'SELECT SurName,FirstName FROM Candidates WHERE '
SET @pSearch2 = 'CONTAINS(AddressTown,''"enf*"'')'
SET @pSearch3 = ' ORDER BY Surname, Firstname'
SET @pSearch1 = @pSearch1 + @pSearch2 + @pSearch3
EXEC (@pSearch1)
However, when I pass 'CONTAINS(AddressTown,''"enf*"'')' to @pSearch2 from vb.net code, I get the error "Incorrect syntax near 'CONTAINS(AddressTown,''"enf*"'')'.
The string is passed in the format:
strBuilder = "'" + "CONTAINS(AddressTown, ''""enf*""'')" + "'"
I have tried various combinations of single and double quotes but it won't have it.
Am I missing something?
DECLARE @pSearch1 as varchar(500), @pSearch2 as varchar(500), @pSearch3 as varchar(500)
SET @pSearch1 = 'SELECT SurName,FirstName FROM Candidates WHERE '
SET @pSearch2 = 'CONTAINS(AddressTown,''"enf*"'')'
SET @pSearch3 = ' ORDER BY Surname, Firstname'
SET @pSearch1 = @pSearch1 + @pSearch2 + @pSearch3
EXEC (@pSearch1)
However, when I pass 'CONTAINS(AddressTown,''"enf*"'')' to @pSearch2 from vb.net code, I get the error "Incorrect syntax near 'CONTAINS(AddressTown,''"enf*"'')'.
The string is passed in the format:
strBuilder = "'" + "CONTAINS(AddressTown, ''""enf*""'')" + "'"
I have tried various combinations of single and double quotes but it won't have it.
Am I missing something?