473,386 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

datagridview not showing its dataset.

Hi all

I have a datagridview, and I want it to show and enable editing of a
table in my mysql database.

I get the results from the sql-query into the dataset, and when I view
the dataset in the debuger with the dataset viewer, I can see that the
dataset is filled with my data, but the datagridview is all grey,
showing no columns and no data.

I cannot figure out what's wrong/missing.
string sqlString = "SELECT * FROM vehicle";

OdbcCommand cm = new OdbcCommand(sqlString, OdbcCon);
DataAdapter da = new OdbcDataAdapter(cm);
da.TableMappings.Add("Table", "vehicle");

DataSet ds = new DataSet("vehicle");
da.Fill(ds);
dataGridView1.AutoGenerateColumns = true;
dataGridView1.DataSource = ds;

--
K

Dec 11 '06 #1
2 11109
Just a thought : try giving the dgv a DataTable rather than the
DataSet, or specify the table name in the dgv's DataMember.

Marc
Dec 11 '06 #2

Marc Gravell wrote:
Just a thought : try giving the dgv a DataTable rather than the
DataSet, or specify the table name in the dgv's DataMember.

Marc
Thanks a bunch, a simple
dataGridView1.DataMember = "vehicle";
did the job.

--
Kristian

Dec 11 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Brian | last post by:
I've got a couple questions on the new Datagridview control in VS2005. 1) In the old datagrid control at design time I was able to add multiple tablestyles with columns from different...
10
by: Henok Girma | last post by:
Hello Gurus, I want to save the state of an unbound DataGridView on my Windows Form application to an XML file so i can later load it back.. Basically, on my form I have a DataGridView, it's got...
2
by: Rick Shaw | last post by:
Hi, I have a problem with the datagridview not refreshed when the application first appear on the screen. The datagridview display data from a table in the dataset. At the same time, I've added...
8
by: | last post by:
I am sure this has been asked and answered, but here goes anyway... VS.Net 2005, VB.Net How can you display more than one field in the displaymember property of a combobox inside the...
4
by: Neeraj | last post by:
hi I am using datagridview and sql Express as a datasource i populate data but not able to update through datagridview i am using such code dataAdpter = new...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
3
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm trying to add a datagridview control to a Windows Form to display read-only information in visual basic 2005. My understanding is that datareader will be faster for this purpose. I have the...
1
by: SePp | last post by:
Hello together, I have a main form which includes a Datatoolstripmenu. From one of these items I want to call a Form which includes an DataGridview. I want to use this form and datagridview as...
3
by: WestAussie | last post by:
Hello I'm trying to populate a DataGridView with a stored procedure using VB.NET. The query I need to use is within a Access 2007 datadase. When I run it in Access it is showing data but the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.