Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Does any one know how to display this on a form in a dataviewgrid I can do it in an console app but I want to dot it in a form



C#
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
              // Retrieve the enumerator instance and then the data.
    SqlDataSourceEnumerator instance =
      SqlDataSourceEnumerator.Instance;
    System.Data.DataTable table = instance.GetDataSources();

    // Display the contents of the table.
    DisplayData(table);

    Console.WriteLine("Press any key to continue.");
    Console.ReadKey();
  }

  private static void DisplayData(System.Data.DataTable table)
  {
    foreach (System.Data.DataRow row in table.Rows)
    {
      foreach (System.Data.DataColumn col in table.Columns)
      {
        Console.WriteLine("{0} = {1}", col.ColumnName, row[col]);
      }
      Console.WriteLine("============================");
    }
  }
Posted
Updated 24-Aug-12 10:01am
v2
Comments
[no name] 24-Aug-12 7:11am    
It would be easier to create a forms application and copy your code to it rather than try and explain to you how to change your console application to a forms application.

1 solution

You just put a gridview or similar on your form, set it's datasource property and call databind()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900