Solved

Displaying data from Access in VB custom DataGridView

Posted on 2006-11-09
2
550 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now