View Single Post
Old 06-15-2004, 11:58 AM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,505
sde is on a distinguished road
i think it would be easier for you to use this approach:
Code:
using System;
using System.Data.SqlClient;

public class Test
{
  public static void Main()
  {
    Test t=new Test();
    t.Run();
  }
  
  public void Run()
  {
    SqlConnection conn = new SqlConnection("Data Source=localhost; Integrated Security=SSPI; Initial Catalog=pubs");
    SqlCommand  cmd = new SqlCommand("SELECT * FROM emp_test", conn);
    try
    {    	
      conn.Open();
      
      SqlDataReader myReader = cmd.ExecuteReader();
      Console.WriteLine("Code \t Emp. Name \t Emp. Phone");
      Console.WriteLine("-----------------------------------------");
      while (myReader.Read())
      {
        Console.WriteLine("{0}\t{1}\t\t{2}", myReader.GetInt32(0), myReader.GetString(1), myReader.GetString(2));
      }
    		
      myReader.Close();
      conn.Close();
    }
    catch(Exception e)
    {
      Console.WriteLine("Exception Occured -->> {0}",e);
    }    	
  }
}
__________________
Mike
sde is offline   Reply With Quote