Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Console.WriteLine - need help

Console.WriteLine - need help

Scheduled Pinned Locked Moved C#
cssdatabasevisual-studiohelpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Slow Learner
    wrote on last edited by
    #1

    Hello, I am trying to run this program in VS 2003. This runs fine but I can't see the results in Vs 2003. Infact I am not using any grid or any thing like that but using Console.WriteLine to print the results. I know that this program prints in the command prompt but I am trying to find an option so that I can see the results in VS 2003 (either command window or any other window). Is there any other line of code that I can use to print the results in VS 2003? static void Main() { //Application.Run(new Form1()); // 1. Instantiate the connection string Connection; Connection = "Data Source='TestServer';Initial Catalog=Northwind;Trusted_Connection=sspi"; //Connection = "Data Source='TestServer';Initial Catalog=Northwind;User id=sa;Pwd=development"; SqlConnection conn = new SqlConnection(Connection); SqlDataReader rdr = null; try { // 2. Open the connection conn.Open(); // 3. Pass the connection to a command object SqlCommand cmd = new SqlCommand("select * from Customers", conn); // // 4. Use the connection // // get query results rdr = cmd.ExecuteReader(); // print the CustomerID of each record while (rdr.Read()) { //Console.WriteLine(rdr[0]); System.Console.WriteLine(rdr[0]); } } catch (Exception ex) { throw ex; } finally { // close the reader if (rdr != null) { rdr.Close(); } // 5. Close the connection if (conn != null) { conn.Close(); } } }

    N I A 3 Replies Last reply
    0
    • S Slow Learner

      Hello, I am trying to run this program in VS 2003. This runs fine but I can't see the results in Vs 2003. Infact I am not using any grid or any thing like that but using Console.WriteLine to print the results. I know that this program prints in the command prompt but I am trying to find an option so that I can see the results in VS 2003 (either command window or any other window). Is there any other line of code that I can use to print the results in VS 2003? static void Main() { //Application.Run(new Form1()); // 1. Instantiate the connection string Connection; Connection = "Data Source='TestServer';Initial Catalog=Northwind;Trusted_Connection=sspi"; //Connection = "Data Source='TestServer';Initial Catalog=Northwind;User id=sa;Pwd=development"; SqlConnection conn = new SqlConnection(Connection); SqlDataReader rdr = null; try { // 2. Open the connection conn.Open(); // 3. Pass the connection to a command object SqlCommand cmd = new SqlCommand("select * from Customers", conn); // // 4. Use the connection // // get query results rdr = cmd.ExecuteReader(); // print the CustomerID of each record while (rdr.Read()) { //Console.WriteLine(rdr[0]); System.Console.WriteLine(rdr[0]); } } catch (Exception ex) { throw ex; } finally { // close the reader if (rdr != null) { rdr.Close(); } // 5. Close the connection if (conn != null) { conn.Close(); } } }

      N Offline
      N Offline
      netJP12L
      wrote on last edited by
      #2

      Writeline the program endstherefore you can't see anything. If you put readline at the end i think you can hold the console window to see the result

      1 Reply Last reply
      0
      • S Slow Learner

        Hello, I am trying to run this program in VS 2003. This runs fine but I can't see the results in Vs 2003. Infact I am not using any grid or any thing like that but using Console.WriteLine to print the results. I know that this program prints in the command prompt but I am trying to find an option so that I can see the results in VS 2003 (either command window or any other window). Is there any other line of code that I can use to print the results in VS 2003? static void Main() { //Application.Run(new Form1()); // 1. Instantiate the connection string Connection; Connection = "Data Source='TestServer';Initial Catalog=Northwind;Trusted_Connection=sspi"; //Connection = "Data Source='TestServer';Initial Catalog=Northwind;User id=sa;Pwd=development"; SqlConnection conn = new SqlConnection(Connection); SqlDataReader rdr = null; try { // 2. Open the connection conn.Open(); // 3. Pass the connection to a command object SqlCommand cmd = new SqlCommand("select * from Customers", conn); // // 4. Use the connection // // get query results rdr = cmd.ExecuteReader(); // print the CustomerID of each record while (rdr.Read()) { //Console.WriteLine(rdr[0]); System.Console.WriteLine(rdr[0]); } } catch (Exception ex) { throw ex; } finally { // close the reader if (rdr != null) { rdr.Close(); } // 5. Close the connection if (conn != null) { conn.Close(); } } }

        I Offline
        I Offline
        isamir
        wrote on last edited by
        #3

        Hi, You can include using System.Diagnostics; and in debug mode you can write in Visual Studio output window by using Debug.WriteLine(" xxxxxxxxxxxxxxx "); I hope it will help -Samir.

        1 Reply Last reply
        0
        • S Slow Learner

          Hello, I am trying to run this program in VS 2003. This runs fine but I can't see the results in Vs 2003. Infact I am not using any grid or any thing like that but using Console.WriteLine to print the results. I know that this program prints in the command prompt but I am trying to find an option so that I can see the results in VS 2003 (either command window or any other window). Is there any other line of code that I can use to print the results in VS 2003? static void Main() { //Application.Run(new Form1()); // 1. Instantiate the connection string Connection; Connection = "Data Source='TestServer';Initial Catalog=Northwind;Trusted_Connection=sspi"; //Connection = "Data Source='TestServer';Initial Catalog=Northwind;User id=sa;Pwd=development"; SqlConnection conn = new SqlConnection(Connection); SqlDataReader rdr = null; try { // 2. Open the connection conn.Open(); // 3. Pass the connection to a command object SqlCommand cmd = new SqlCommand("select * from Customers", conn); // // 4. Use the connection // // get query results rdr = cmd.ExecuteReader(); // print the CustomerID of each record while (rdr.Read()) { //Console.WriteLine(rdr[0]); System.Console.WriteLine(rdr[0]); } } catch (Exception ex) { throw ex; } finally { // close the reader if (rdr != null) { rdr.Close(); } // 5. Close the connection if (conn != null) { conn.Close(); } } }

          A Offline
          A Offline
          Abdul Sami X
          wrote on last edited by
          #4

          There is only one way to do this. Write the output into a text file and open that file in the VS 2003 at run time. I hope, you got answer for your question.

          Sr. Software Engineer Irevna, India

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups