G
graphicsxp
Hi,
I have a SQL stored procedure which looks like that:
SELECT @QuerySQL = 'SELECT [' + @LookupField + '] as LookupField,
G.GroupDesc + ' + '" : "' + ' + [' + @DescField + '] as DescField
FROM [' + @TableName + ']'
+ 'JOIN ItemGrouping IG on IG.CatID =' + cast(@CatID as varchar(50)) +
'and ItemID = [' + @LookupField + ']
JOIN [Grouping] G on G.GroupID = IG.GroupID
ORDER BY DescField'
EXEC @QuerySQL
Pretty tricky... but it works fine. The SQLServer Query Analyser
returns the expected records and the field DescField looks like :
somestring : someotherstring, so the concatenation works.
However, on the .Net side, when I do ExecuteNonQuery to fill my
Datatable, I get the following exception:
Invalid column name ' : '
I don't understand why it's trying to pick it up as a column, since
DescField should just be a varchar field made up of the concatenation
of @LookupField + ':' + @DescField
Any clue ?
Thanks
I have a SQL stored procedure which looks like that:
SELECT @QuerySQL = 'SELECT [' + @LookupField + '] as LookupField,
G.GroupDesc + ' + '" : "' + ' + [' + @DescField + '] as DescField
FROM [' + @TableName + ']'
+ 'JOIN ItemGrouping IG on IG.CatID =' + cast(@CatID as varchar(50)) +
'and ItemID = [' + @LookupField + ']
JOIN [Grouping] G on G.GroupID = IG.GroupID
ORDER BY DescField'
EXEC @QuerySQL
Pretty tricky... but it works fine. The SQLServer Query Analyser
returns the expected records and the field DescField looks like :
somestring : someotherstring, so the concatenation works.
However, on the .Net side, when I do ExecuteNonQuery to fill my
Datatable, I get the following exception:
Invalid column name ' : '
I don't understand why it's trying to pick it up as a column, since
DescField should just be a varchar field made up of the concatenation
of @LookupField + ':' + @DescField
Any clue ?
Thanks