none
Read Data From Excel File RRS feed

  • Question

  • Private Sub DoMSExcel(ByRef ds As DataSet)
                Dim selectConnection As New OleDbConnection
                selectConnection.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Me.myFilePath & "; Extended Properties=""Excel 8.0;""")
                selectConnection.Open()
                Try
                    enumerator = Me.TablesMapped.Keys.GetEnumerator
                    Do While enumerator.MoveNext
                        Dim dataSetTable As String = Conversions.ToString(enumerator.Current)
                        Try
                            Dim sourceTable As String = Conversions.ToString(Operators.ConcatenateObject(Operators.ConcatenateObject("[", Me.TablesMapped.Item(dataSetTable)), "]"))
                            Dim adapter As New OleDbDataAdapter(("select * from " & sourceTable), selectConnection)
                            adapter.TableMappings.Add(sourceTable, dataSetTable)
                            adapter.Fill(ds, dataSetTable)

     

    Exception :

    I am getting  error

    The Microsoft Jet database engine could not find the object 'abcgroup'.  Make sure the object exists and that you spell its name and the path name correctly.

    how can i fix this error
    • Moved by SamAgain Friday, October 8, 2010 3:38 AM better fit (From:.NET Base Class Library)
    • Moved by Bessie Zhao Friday, October 8, 2010 6:29 AM (From:Excel for Developers)
    Thursday, October 7, 2010 5:56 AM

Answers

  • Hello,

    Here is a code snippet to retrieve data using DataSet object.

       '========================================================
       'Use a DataSet to read data from the InventoryData table.
       '========================================================
       Dim conn2 As New OleDbConnection(m_sConn2)
       Dim da As New OleDbDataAdapter("Select * From [InventoryData$]", conn2)
       Dim ds As DataSet = New DataSet()
       da.Fill(ds)
       Debug.WriteLine(vbCrLf & "InventoryData:" & vbCrLf & "==============")
       Dim dr As DataRow
       For Each dr In ds.Tables(0).Rows'Show results in output window
         Debug.WriteLine(System.String.Format("{0,-15}{1, -6}{2}", _
          dr("Product"), dr("Qty"), dr("Price")))
       Next
       conn2.Close()
    
    

    Here is a KB article demonstrated that:
    http://support.microsoft.com/kb/316934

    Please have a try and let me know the result. If the issue persists, please tell us on which line does the error occur.
    Thanks a lot!


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    • Marked as answer by liurong luo Thursday, October 21, 2010 1:38 AM
    Wednesday, October 13, 2010 8:46 AM

All replies

  • Hello Mohammad,

    I will move this thread to ADO.NET Dataset forum. You will probably get more helps from experts there.

    Thanks,
    Bessie 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Friday, October 8, 2010 6:29 AM
  • Hello,

    Here is a code snippet to retrieve data using DataSet object.

       '========================================================
       'Use a DataSet to read data from the InventoryData table.
       '========================================================
       Dim conn2 As New OleDbConnection(m_sConn2)
       Dim da As New OleDbDataAdapter("Select * From [InventoryData$]", conn2)
       Dim ds As DataSet = New DataSet()
       da.Fill(ds)
       Debug.WriteLine(vbCrLf & "InventoryData:" & vbCrLf & "==============")
       Dim dr As DataRow
       For Each dr In ds.Tables(0).Rows'Show results in output window
         Debug.WriteLine(System.String.Format("{0,-15}{1, -6}{2}", _
          dr("Product"), dr("Qty"), dr("Price")))
       Next
       conn2.Close()
    
    

    Here is a KB article demonstrated that:
    http://support.microsoft.com/kb/316934

    Please have a try and let me know the result. If the issue persists, please tell us on which line does the error occur.
    Thanks a lot!


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    • Marked as answer by liurong luo Thursday, October 21, 2010 1:38 AM
    Wednesday, October 13, 2010 8:46 AM