Hello I have a Gridview that is updating and inserting information into my tables. I am using the following query to insert:
Dim InsStr = _
"IF NOT EXISTS" & _
"(SELECT [PRODUCT_NAME] FROM [PRODUCT] WHERE [PRODUCT_NAME] = '" + ProdName + "'" & _
" UNION " & _
" SELECT [PRODUCT_MODEL] FROM [PRODUCT] WHERE [PRODUCT_MODEL] = '" + ProdModel + "')" & _
"INSERT INTO [PRODUCT] " & _
"([PRODUCT_CATAGORY], [PRODUCT_NAME],[PRODUCT_DESCRIPTION]," & _
"[PRODUCT_MODEL] , [PRODUCT_MANUFACTURER])" & _
"VALUES ( " & _
"'" + ProdCatagory + "'," & _
"'" + ProdName + "'," & _
"'" + ProdDescription + "'," & _
"'" + ProdModel + "'," & _
"'" + ProdManufacturer + "')"
It won't insert if the name or model number matches any existing rows, so it works.. the issue is I have no way of letting the user know that his/her row didn't update/insert because of a duplicate model/product name. In my SQL Studio I run the command with a duplicate name or model and the result will be:
Command(s) completed successfully.
If it inserts it will be:
1 Row Affected
How can i check these conditions pragmatically with my asp code?
Thanks! :)