TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kamil Zahid
NA
6
22.6k
How to Display Data from MySql Database on DataGridView in C#
Mar 27 2011 10:24 AM
Hi Guys
I really need some help here, I have used the following to code to display information from my database into visual Studio DataGridView but it displays the attributes and not the actual data values. I don't understand why:
public void BindCustomerDataToGrid()
{
MySqlConnection cn = new MySqlConnection("SERVER=localhost;" + "DATABASE=clientmanagement;" + "UID=root;" + "PASSWORD=qwerty;");
{
DataTable customerTable = new DataTable();
string query = "select c.customer_name, c.phone, a.ytd_sale from customer c, account a where c.customer_id = a.customer_id;";
MySqlDataAdapter dataAdaptar = new MySqlDataAdapter(query, cn);
MySqlCommandBuilder cmd = new MySqlCommandBuilder(dataAdaptar);
customerTable.Locale = System.Globalization.CultureInfo.InvariantCulture;
dataAdaptar.Fill(customerTable);
BindingSource customerDataBindingSource = new BindingSource();
customerDataBindingSource.DataSource = customerTable;
dataGridView1.DataSource = customerDataBindingSource;
}
}
Your Help will be really much appreciated.
Reply
Answers (
1
)
queue
foreach loop