C1 Community
ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Help populating grid

rated by 0 users
This post has 5 Replies | 1 Follower

Not Ranked
Posts 4
cgydosh Posted: Tue, Jun 2 2009 10:48 AM

 Hi, I want to have an editable grid and my code follows.  Would someone be able to tell me where I'm going wrong here?  I'm getting this error message on the last line.

Unable to cast object of type 'System.Data.DataSet' to type 'msdatasrc.DataSource'


 Thanks

 Carl

 

 Dim SQL As String
        Dim myDataSet As New DataSet
        Dim myDataAdaptor As OleDb.OleDbDataAdapter

        SQL = "SELECT * FROM UnitOfMeasureType"

        myDataAdaptor = New OleDb.OleDbDataAdapter(SQL, ConnectionProvider.Instance.Connection)

        myDataAdaptor.Fill(myDataSet, "UnitOfMeasureType")

        AxVSFlexGrid1.DataSource = myDataSet

Top 25 Contributor
Posts 455
C1_GaryB replied on Thu, Jul 2 2009 10:53 AM

Hello,

 

I made few changes to the code and it works fine at my machine.

 

BEGIN CODE#
        Dim SQL As String = "Select * from Suppliers"

        Dim myDataSet As New DataSet

        Dim myDataAdaptor As OleDb.OleDbDataAdapter

 

        SQL = "SELECT * FROM Suppliers"

 

        myDataAdaptor = New OleDb.OleDbDataAdapter(SQL, "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Program Files\ComponentOne Studio.NET 2.0\Common\nwind.mdb")

 

        myDataAdaptor.Fill(myDataSet, "Suppliers")

 

        Me.C1FlexGrid1.DataSource = myDataSet.Tables("Suppliers")

END CODE#

 

Kindly observe the same.

 

Regards,

C1_GaryB.

<cgydosh> wrote in message news:218545@10.0.1.98...

 Hi, I want to have an editable grid and my code follows.  Would someone be able to tell me where I'm going wrong here?  I'm getting this error message on the last line.

Unable to cast object of type 'System.Data.DataSet' to type 'msdatasrc.DataSource'


 Thanks

 Carl

 

 Dim SQL As String
        Dim myDataSet As New DataSet
        Dim myDataAdaptor As OleDb.OleDbDataAdapter

        SQL = "SELECT * FROM UnitOfMeasureType"

        myDataAdaptor = New OleDb.OleDbDataAdapter(SQL, ConnectionProvider.Instance.Connection)

        myDataAdaptor.Fill(myDataSet, "UnitOfMeasureType")

        AxVSFlexGrid1.DataSource = myDataSet



http://helpcentral.componentone.com/cs/forums/p/79413/218545.aspx#218545

Not Ranked
Posts 4
cgydosh replied on Mon, Jul 6 2009 9:47 AM

 Thanks for the reply, but I still get the same error message.

 I don't get the problem when I use the Microsoft grid, but  I want to use the C1 grid for this project.

 

Carl

 

 

Not Ranked
Posts 4
cgydosh replied on Mon, Jul 6 2009 10:03 AM

This is interesting.

 

I noticed the only real difference between your code and mine is that I am using an Oracle DB and you are using an Access file.

 I changed my code to read from an Access file as you did and I still get the same error message.

 

Carl

 

Top 75 Contributor
Posts 80
AIBofMASS replied on Mon, Jul 6 2009 12:37 PM

Note that Gary's code is setting the datasource to a data table, while you are setting it to a dataset.

Not Ranked
Posts 4
cgydosh replied on Mon, Jul 6 2009 1:27 PM

AIBofMASS:

Note that Gary's code is setting the datasource to a data table, while you are setting it to a dataset.

 

 

I did notice that and fix it and still get the same error.

 I actually tried a copy/paste of his code (I changed the path to the db) and still got the error.

 

Page 1 of 1 (6 items) | RSS
Contact ComponentOne: 1.800.858.2739 ©1987-2010 ComponentOne LLC All Rights Reserved.