Results 1 to 4 of 4

Thread: NextRow

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2010
    Location
    Hungary
    Posts
    10

    NextRow

    Why do not see the next record in this sample? Only the first!

    Public Sub Mutat() Handles MyBase.Load
    connectionStr = "Driver={Driver do Microsoft dBase (*.dbf)};" & _
    "collatingsequence=ASCII;defaultdir=C:\Syn;" & _
    "deleted=0;driverid=21;fil=dBase III;filedsn=C:\Syn\PROBA.DBF.dsn;" & _
    "maxbuffersize=2048;maxscanrows=8;pagetimeout=5;safetransactions=0 ;" & _
    "statistics=0;threads=3;uid=admin;usercommitsync=Yes"

    readSQL = "SELECT 'knev','vnev' FROM C:\Syn\PROBA.DBF"

    Using connection As New OdbcConnection(connectionStr)
    Dim command As New OdbcCommand(readSQL, connection)
    Dim odr As OdbcDataReader
    Dim txt As String
    Try
    connection.Open()
    odr = command.ExecuteReader
    While odr.Read()
    txt = odr(0).ToString & odr(1).ToString
    MsgBox(txt)
    End While
    Catch ex As Exception
    MsgBox(ex.Message)
    End Try
    MsgBox("Open")
    End Using
    End Sub

    Help me!

    István

  2. #2
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: NextRow

    Try pushing the data to a DataTable as follows. The Data Source points to the path where the DBF exists and the SELECT statement points to the physical DBF table name. If that works then go back to a DataReader.

    Code:
    If IO.File.Exists("C:\Data\TEST.DBF") Then
        Dim cn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
                                            "Data Source=C:\Data;Extended Properties=dBase III")
        cn.Open()
    
        Dim cmd As New OleDb.OleDbCommand("SELECT * FROM TEST")
        cmd.Connection = cn
        Dim dt As New DataTable
        dt.Load(cmd.ExecuteReader)
    
        DataGridView1.DataSource = dt
    End If
    So if you had three DBF files under C:\Data then the following code would show three items in the ListBox.

    Code:
    Dim cn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
                                        "Data Source=C:\Data;Extended Properties=dBase III")
    cn.Open()
    
    Dim DatabaseSchema As New DataTable
    
    DatabaseSchema = cn.GetOleDbSchemaTable(OleDb.OleDbSchemaGuid.Tables, _
                                                        New Object() {Nothing, Nothing, Nothing, "TABLE"})
    
    ListBox1.DisplayMember = "TABLE_NAME"
    ListBox1.DataSource = DatabaseSchema

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2010
    Location
    Hungary
    Posts
    10

    Re: NextRow

    The first code is working well. Thanks for You!
    The secound no. See "NextRecord 2"

  4. #4
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: NextRow

    Quote Originally Posted by hodnagy View Post
    The secound no. See "NextRecord 2"
    Either the samples work or they do not work, care to explain in detail.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width