int ScriptId = 0;
string sql = "Select Max(ScriptId) from tbl_Script";
SqlCommand cmd = new SqlCommand(sql, connection);
using (var reader = cmd.ExecuteReader())
{
if (reader["ScriptId"] == System.DBNull.Value)
{
ScriptId += 1;
}
else
{
ScriptId = ScriptId++;
}
}
this is my code i am face same error (IndexOutOfRangeException was unhandled) this is an issue pls let me know ans