Advertisement

01.20.2006 at 08:04AM PST, ID: 21704168
[x]
Attachment Details

Bind a dataset to a datagridview

Asked by ITHELP25 in Microsoft Visual Basic.Net

Tags: datagridview, dataset, bind

We recently purchased and started using Visual Studio 2005.  We are trying to create an application in Visual Basic that has a datagrid which displays data from a SQL select statement (dataset).  In Visual Studio 2003 the code below works fine, with a datagrid (in 2003 it's called a datagrid, in 2005 a datagridview not sure if thats the difference?) however the same code does not populate the datagridview in 2005.  We don't get any errors, just no results in the grid.

Dim cn As New SqlConnection("Data Source=TESTSVR;Initial Catalog=JDE_CRP;Persist Security Info=True;User ID=TEST;password=TEST")
            ' Create a new SqlDataAdapter and pass the SQL Statement
            ' and connection object
            Dim da As SqlDataAdapter = New SqlDataAdapter _

                ("SELECT FIELD1, FIELD2 from TABLE", cn)
            ' Create a DataSet to hold the SqlDataAdapter data
            Dim ds As DataSet = New DataSet("Test")
            ' Call the Fill method to load the DataSet

            da.Fill(ds)

            ' Set the DataSource property of the grid
            ' to bind the data from the DataSet

            DataGrid1.DataSource = ds

 
Start Free Trial
[+][-]01.20.2006 at 08:18AM PST, ID: 15750239

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]01.20.2006 at 08:42AM PST, ID: 15750449

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.20.2006 at 08:58AM PST, ID: 15750616

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.20.2006 at 09:12AM PST, ID: 15750771

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.20.2006 at 10:46AM PST, ID: 15751558

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.21.2006 at 01:25PM PST, ID: 15757888

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.23.2006 at 03:08AM PST, ID: 15764950

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.23.2006 at 05:15PM PST, ID: 15772119

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual Basic.Net
Tags: datagridview, dataset, bind
Sign Up Now!
Solution Provided By: PAQ_Man
Participating Experts: 2
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32