?
Solved

Displaying data from Access in VB custom DataGridView

Posted on 2006-11-09
2
Medium Priority
?
557 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 400 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

649 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