Results 1 to 2 of 2

Thread: Returning Wrong Value

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Returning Wrong Value

    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);
    		}
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  2. #2

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    nevermind..I got it figured out.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width