MbahAgis

Load FoxPro 2.6 file (.DBF) to DataGridView

Jan 25th, 2021 (edited)
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.64 KB | None | 0 0
  1. 'FoxPro 2.6
  2. 'vdos = https://www.vdos.info/download.php
  3. 'ConnectionString = https://www.connectionstrings.com/dbf-foxpro/
  4.  
  5. 'OLEDB - Data Source = Folder Path
  6. 'ODBC - DBQ = Folder Path
  7. 'CommandText = Select * From FileName.dbf
  8.  
  9. 'ODBC Data Source Administrator shortcut, Win + R (Run dialog) then type odbcad32
  10. 'Check Drivers Tab
  11. 'Example: Driver={Microsoft Access dBASE Driver (*.dbf, *.ndx, *.mdx)}
  12.  
  13. Imports System.Data.Odbc
  14. Imports System.Data.OleDb
  15. Public Class Form1
  16.     Private Sub BtnLoadOLEDB_Click(sender As Object, e As EventArgs) Handles BtnLoadOLEDB.Click
  17.         Using con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;
  18.                                          Data Source=C:\vDos\FPD26\SAMPLE\CATALOG\;
  19.                                          Extended Properties=dBASE IV;")
  20.             Using adp As New OleDbDataAdapter("Select * From CUSTOMER.DBF", con)
  21.                 Using DT As New DataTable
  22.                     adp.Fill(DT)
  23.                     DGV.DataSource = DT
  24.                 End Using
  25.             End Using
  26.         End Using
  27.     End Sub
  28.  
  29.     Private Sub BtnLoadODBC_Click(sender As Object, e As EventArgs) Handles BtnLoadODBC.Click
  30.         Using con As New OdbcConnection("Driver={Microsoft Access dBASE Driver (*.dbf, *.ndx, *.mdx)};
  31.                                          Dbq=C:\vDos\FPD26\SAMPLE\CATALOG\;")
  32.             Using adp As New OdbcDataAdapter("Select * From CUSTOMER.DBF", con)
  33.                 Using DT As New DataTable
  34.                     adp.Fill(DT)
  35.                     DGV.DataSource = DT
  36.                 End Using
  37.             End Using
  38.         End Using
  39.     End Sub
  40. End Class
  41.  
Add Comment
Please, Sign In to add comment