Everything worked fine, even for handling null values I declared Nullable Variables (see a list of tips on Nullable Types in GPS)
But, suddenly to my surprise I found that it was still throwing error like "Cannot convert System.DBNull to Nullable ...." .
So the actual problem lies in the type, remember System.DBNull is something different from null. As i was returning the data type as dynamic, and whenever it encountered System.DBNull, it became System.DBNull.
Now i checked my dynamic result with System.DBNull, like
dynamic result = FunctionToReturnScalarValue(randomSql) ;
if(result != System.DBNull.Value)
{ requiredVariable = result;}
I checked it first for the null result, it worked fine, but when the Scalar Result was present in the DB, it again threw an exception :( (something like Cannot convert Int32 to System.DBNull...)