Solved

Displaying data from Access in VB custom DataGridView

Posted on 2006-11-09
2
554 Views
Last Modified: 2008-01-09
Hello,

I have two forms in my applications form Managing Employees and the Courses that participate.

The first from is the one in which i add a new employee in the database and associate the specific employee with available courses. On this form, a datagridview is responsible for binding the courses with the trainee. The datagridview has the following 5 columns.

1) Course Name - combobox - databound

2)Course Type - combobox -databound

3)From Date -DateTimePicker

4)To Date - DateTimePicker

5)Course Provider - Textbox

the above databound comboboxes get date from a dataset (dsCourses)

This form works fine, i can add a new trainee to the database and also i can enroll the specific employee to various courses.

So far so good.

I have  a second form though, that i wish to use for editing the employee information such as enrolled courses e.t.c

What i have done so far, is to create the same custom datagridview as above, but my problem is that i don't know how to fill the datagrid with the courses that the specific employee is enrolled to.

My problem is not the SQL statement to retrieve the data, but rather the way that i will fill the datagridview.

Can you please provide me with some suggestions?

 

Thank you in advanced.
0
Comment
Question by:Globemaster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:Globemaster
ID: 17915115
Anyone with a suggestion??
0
 
LVL 1

Accepted Solution

by:
kulkarnivishwajit earned 100 total points
ID: 17985000
Hi,

You can fill up data in the following way:

private void OnFormLoad(object sender, EventArgs e)
{
   // Create adapter to get data source
   CustomersTableAdapter adapter = new CustomersTableAdapter();
   // Get data set instance
   CustomersDataSet customers = new CustomersDataSet();
   // Fill data set   adapter.Fill(customers);
   // Bind binding source to the data set
   m_CustomersBinding source.DataSource = customers;
   // Bind grid to the Customers table within the data source
   m_Grid.DataSource = m_CustomersBinding source;
   m_Grid.DataMember = "Customers";
}

Alternatively, if the binding source is bound to a collection of data collections, such as a data set, then you can refine what part of the data source you want to bind to using the DataMember property:

private void OnFormLoad(object sender, EventArgs e)
{
   // Create adapter to get data source
   CustomersTableAdapter adapter = new CustomersTableAdapter();
   // Get data set instance
   CustomersDataSet customers = new CustomersDataSet();
   // Fill data set   adapter.Fill(customers);
   // Bind binding source to the data set
   m_CustomersBinding source.DataSource = customers;
   // Bind grid to the Customers table within the data source
   m_Grid.DataSource = m_CustomersBinding source;
   m_Grid.DataMember = "Customers";
}
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question