troubleshooting Question

How to move to next record in OLEDB

Avatar of bobdowdy
bobdowdy asked on
Visual Basic.NET
3 Comments1 Solution1240 ViewsLast Modified:
Simple question from a relative beginner ... I am reading an excel file into, using oledb access.

I open the file, load a dataset, and can see the columns in the first record ... but have gone completely blank on how to navigate to the next record.  My code is below.  Please notice the next to last line - this is where I need to go to next record.

All help greatly appreciated - extra points are for speedy reply !

Dim i As Long
        Dim Col1data As String
        Dim Col2data As String
        Dim Col3data As String
        Dim Col4data As String
        Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + xlFileName + ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""")
        Dim sq As New OleDbDataAdapter("select * from [Sheet1$]", con)
        Dim ds As New DataSet
        Catch ex As Exception
        End Try
        For i = 0 To ds.Tables(0).Rows.Count
            Col1data = ds.Tables(0).Columns(0).ToString()
            Col2data = ds.Tables(0).Columns(1).ToString()
            Col3data = ds.Tables(0).Columns(2).ToString()
            Col4data = ds.Tables(0).Columns(3).ToString()
            '??????????? HOW DO I MOVE TO NEXT RECORD????????????????????
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros