Solved

Displaying data from Access in VB custom DataGridView

Posted on 2006-11-09
2
547 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
Comment Utility
Anyone with a suggestion??
0
 
LVL 1

Accepted Solution

by:
kulkarnivishwajit earned 100 total points
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
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:…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

743 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

16 Experts available now in Live!

Get 1:1 Help Now