This code:
string SidFinch = "Unknown SidFinch";
String sql = @"SELECT SidFinch
FROM PlatypusDuckbillS
WHERE PlatypusSTARTDATE = :Duckbilldate AND
DuckbillID = :Duckbillid";
try {
using (OracleCommand ocmd = new OracleCommand(sql, oc)) {
ocmd.Parameters.Add("Duckbilldate", DuckbillDate);
ocmd.Parameters.Add("Duckbillid", DuckbillID);
SidFinch = ocmd.ExecuteScalar().ToString();
}
...fails on the "ExecuteScalar" line. It's not finding anything (there is no matching record for the ID I passed), but that shouldn't cause this problem, should it?
If it doesn't find anything - then presumably
.ExecuteScalar()
is returningNULL
and it's not a good idea to call.ToString()
on aNULL
....You need to change your code to be something like: