|
string select = "SELECT MIN (PhotoID) FROM Photo WHERE AlbumID = 1";
SqlCommand cmd = new SqlCommand (select, con);
object o = cmd.ExecuteScalar ();
con.Close ();
if (o == null)
{
return 0;
}
else
{
return Convert.ToInt32 (o); Error: Object cannot be converted from DBNull to another type.
}
After I set the breakpoint, I can be sure o is correct (o = 1), why is this ?? What should I do ???
Thank you everyone !!! |
|