Dealing with Database Reader to avoid errors when DB has null value
Introduction Yesterday we were working on a project with my team and we were getting an error message on our production server when I looked at the code, I found titled error. To fix this I am using following code: string connectionString = ConfigurationManager .ConnectionStrings[ "ApplicationServices" ].ConnectionString; SqlConnection conn = new SqlConnection (connectionString); conn.Open(); SqlCommand command = new SqlCommand ( "SELECT * FROM NewReRegistration WHERE rollnumber=@RollNumber" , conn); command.Parameters.Add( new SqlParameter ( "RollNumber" , RollNumber)); SqlDataReader reader = command.ExecuteReader(); ...