How to add Visual Foxpro Database into Visual Basic Express 2005

I have just install Visual Basic Express 2005. Only database from MS Access and MS SQL can be link to this VB. Can any one tell me how to link to Visual Foxpro 6 database Thank you.

Answer this question

How to add Visual Foxpro Database into Visual Basic Express 2005

  • PaulvZyl


    There are several methods you can try. If you use the OLEDB provider you may have to download it:

    Microsoft OLE DB Provider for Visual FoxPro 9.0

         Public Sub ConnectToFoxProODBC()

            Dim ODBCConnection As Microsoft.Data.Odbc.OdbcConnection
            Dim FoxProReader As Microsoft.Data.Odbc.OdbcDataReader

            Dim sConnString As String = _
                        "Driver={Microsoft Visual FoxPro Driver};" & _
                        "SourceType=DBF;" & _
                        "SourceDB=C:\Documents and Settings\...\My Documents\My Database\FoxPro;" & _
                        "Exclusive=No;"

            ODBCConnection = New Microsoft.Data.Odbc.OdbcConnection(sConnString)
            ODBCConnection.Open()

            Dim FoxProCommand As New Microsoft.Data.Odbc.OdbcCommand("Select * from FPDB", ODBCConnection)

            FoxProReader = FoxProCommand.ExecuteReader

            '...
            '...

            ODBCConnection.Close()
            ODBCConnection = Nothing

        End Sub

        Public Sub ConnectToFoxProOLEDB()

            Dim OleDbConnection As System.Data.OleDb.OleDbConnection
            Dim FoxProReader As System.Data.OleDb.OleDbDataReader

            'Database container
            Dim sConnString As String = _
                        "Provider=vfpoledb.1;Data Source=C:\MyDbFolder\MyDbContainer.dbc;Collating Sequence=machine"

            'Free table
            'Dim sConnString As String = _
            '    "Provider=vfpoledb.1;Data Source=C:\MyDataDirectory\;Collating Sequence=general"

            'ODBC DSN
            'Dim sConnString As String = _
            '    "Provider=vfpoledb.1;DSN=MyDSN"

            OleDbConnection = New System.Data.OleDb.OleDbConnection(sConnString)
            OleDbConnection.Open()

            Dim FoxProCommand As New System.Data.OleDb.OleDbCommand("Select * from Table", OleDbConnection)

            FoxProReader = FoxProCommand.ExecuteReader

            '...
            '...

            OleDbConnection.Close()
            OleDbConnection = Nothing

        End Sub

    The OLEDB connection strings are from www.connectionstrings.com



  • Patrick_msdn


    The data tools for the Express editions do not support Visual FoxPro. Only Access and SQL Server are supported. However, it is still possible to connect to a Visual FoxPro database using ADO.NET code.



  • tkt0099

    Well, thank you Paul, mind to show me how to use ADO.Net code in VB to connect to VFP 6
  • How to add Visual Foxpro Database into Visual Basic Express 2005