Hi,
Is it possible to have an if or case type statement in the SelectCommand in Formview?
I have a combobox and if the item doesn't exit I need to add it to the lookup table and then if it does exist, I need to just insert the value into the main table.
So it would be something like this:
InsertCommand="
INSERT INTO [Category] (CategoryName)
SELECT DISTINCT @Category as CategoryName FROM Category
WHERE @Category NOT In (select CategoryName from Category)
SET @CategoryID = SCOPE_IDENTITY();
2nd condition would be:
SELECT @Category as CategoryName FROM Category
WHERE EXISTS (select CategoryName from Category)
SET @CategoryID = @Category;
Both conditions:
INSERT INTO [Product] ([Category]) VALUES (@CategoryID) "
Thanks so much
Is it possible to have an if or case type statement in the SelectCommand in Formview?
I have a combobox and if the item doesn't exit I need to add it to the lookup table and then if it does exist, I need to just insert the value into the main table.
So it would be something like this:
InsertCommand="
INSERT INTO [Category] (CategoryName)
SELECT DISTINCT @Category as CategoryName FROM Category
WHERE @Category NOT In (select CategoryName from Category)
SET @CategoryID = SCOPE_IDENTITY();
2nd condition would be:
SELECT @Category as CategoryName FROM Category
WHERE EXISTS (select CategoryName from Category)
SET @CategoryID = @Category;
Both conditions:
INSERT INTO [Product] ([Category]) VALUES (@CategoryID) "
Thanks so much