raju m

raju m

  • NA
  • 3
  • 665

Object cannot be cast from DBNull to other types.

Dec 19 2015 5:52 AM
my code is
private int GetNextStudentID()
{
command.CommandText = "SELECT IDENT_CURRENT ('admn') + IDENT_INCR ('admn')";
try
{
connection.Open();
int nextID = Convert.ToInt32(command.ExecuteScalar());// here i am getting error
return nextID;
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
connection.Close();
}
return 0;
}
 

Answers (2)