I’m working with SQL now in my programming, and I’m querying a database, like so.
scCommand = new SqlCommand("SELECT LegislationID FROM Legislation WHERE Number = @ECERegulation", sconConnection);
scCommand.Parameters.Add("@ECERegulation", SqlDbType.NVarChar);
scCommand.Parameters["@ECERegulation"].Value = strECERegulation;
return (int)scCommand.ExecuteScalar();
My question is, what would be returned if my parameter did not match anything in the table that I am querying? I need to have an if statement to deal with a non-matching ECERegulation. Would it return null? Or would it return the LegislationID of zero? Any help would be appreciated.
The docs: