May I know how to check the values in a database table when there is no exist data?
I wrote this SQL script and C# code to test the condition statement. But it doesn't work.
In SQL stored procedures I have tried Select * from Table
and check if the condition is 0
DECLARE @CheckFindQTY FLOAT
SET @CheckFindQTY = (SELECT INV_QTY FROM OTH_INV_QTY_LOC
WHERE INV_ID = @INV_ID
AND INV_LOCATION = @INV_LOCATION
AND INV_QTY = @INV_QTY)
IF @CheckFindQTY = 0
BEGIN
SELECT @RecordFound = 3
END
And also I tried checking if the condition is NULL
DECLARE @CheckFindQTY FLOAT
SET @CheckFindQTY = (SELECT INV_QTY
FROM OTH_INV_QTY_LOC
WHERE INV_ID = @INV_ID
AND INV_LOCATION = @INV_LOCATION
AND INV_QTY = @INV_QTY)
IF @CheckFindQTY = NULL
BEGIN
SELECT @RecordFound = 3
END
Then I query the condition in C# if the condition is == 3 then show alert message
int recordFound = Convert.ToInt32(_cmd.Parameters["@RecordFound"].Value);
if (recordFound == 3)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('There is not QTY in Location, please check again!!')", true);
}
Note that the test for a NULL value is
IS NULL
, not= NULL
.