I got the above error in my app. Here is the original code
public string GetCustomerNumber(Guid id) { string accountNumber = (string)DBSqlHel
I suppose you can do it like this:
string accountNumber = DBSqlHelperFactory.ExecuteScalar(...) as string;
If accountNumber is null it means it was DBNull not string :)