locked
How to print the contents of a database?

    Question

  • Hi,

     

    I have a database with several records and want to print it contents.

    How a retrieve all the entrys in the database?

     

    I am using DataSet ans no GridVieuw,

     

    Thanks

    Tuesday, June 12, 2007 7:57 PM

Answers

  • hi vs programmer,

     

    I've found it, however i aske myself if there is not an easier way:

     

    Code Snippet

    StringBuilder printDatabase = new StringBuilder();

    int listing = listingBindingSource.Count;

    int currentPosition = listingBindingSource.Position;

    listingBindingSource.MoveFirst();

    BindingSource Source = new BindingSource();

    DataTable dataTable = new DataTable();

    PropertyDescriptor value;

    for (int i = 0; i < listing; i++)

    {

    listingBindingSource.Position = i;

    dataTable = carTrackerDataSet.Color.ColorNameColumn.Table; // Source.GetItemProperties(null)["DateSeen"];

    Source.DataSource = dataTable;

    value = Source.GetItemProperties(null)["ColorName"];

    if (value != null)

    {

    string str = value.GetValue(colorBindingSource.Current).ToString();

    printDatabase.Append(str + " ");

    }

     

    and that for each table, but it works Smile

     

    Wednesday, June 13, 2007 6:41 PM

All replies

  • What type of database?  SQL???

     

    Just search for all entries but leave the limitby options blank and fill the other options with all the availible rows/datasets.

     

    Hope this helps

    Wednesday, June 13, 2007 12:24 AM
  • hi vs programmer,

     

    I've found it, however i aske myself if there is not an easier way:

     

    Code Snippet

    StringBuilder printDatabase = new StringBuilder();

    int listing = listingBindingSource.Count;

    int currentPosition = listingBindingSource.Position;

    listingBindingSource.MoveFirst();

    BindingSource Source = new BindingSource();

    DataTable dataTable = new DataTable();

    PropertyDescriptor value;

    for (int i = 0; i < listing; i++)

    {

    listingBindingSource.Position = i;

    dataTable = carTrackerDataSet.Color.ColorNameColumn.Table; // Source.GetItemProperties(null)["DateSeen"];

    Source.DataSource = dataTable;

    value = Source.GetItemProperties(null)["ColorName"];

    if (value != null)

    {

    string str = value.GetValue(colorBindingSource.Current).ToString();

    printDatabase.Append(str + " ");

    }

     

    and that for each table, but it works Smile

     

    Wednesday, June 13, 2007 6:41 PM