Help populating grid

WinForms

ComponentOne's WinForms controls

Help populating grid

  • rated by 0 users
  • This post has 5 Replies |
  • 1 Follower
  •  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

  • 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

  •  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

     

     

  • 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

     

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

  • 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)