Just a simple console application that connects to a database.
sql statement returns a job_id...I ask the user to enter the job_id they are interested in...they enter the job_id and I am test what they enter...for some reason when they enter an ID # it is printing the wrong value back to the console...for instance say I enter Id 14 it prints "The Id you selected is 49"...anyone know what is going on here?
Code:SqlConnection conn = new SqlConnection(connString); SqlCommand comm = new SqlCommand(query, conn); SqlDataReader reader; try { conn.Open(); reader = comm.ExecuteReader(); Console.WriteLine("JobId"); Console.WriteLine(); while(reader.Read()) { Console.WriteLine(reader["job_id"]); } reader.Close(); Console.WriteLine("Please select a JobId from the list above."); int Id = Console.Read(); Console.WriteLine("The Id you selected was: {0}", Id); '<----------- } catch(Exception e) { Console.WriteLine("{0} exception caught!", e); }




Reply With Quote