2023年6月27日 星期二

Using .dbf database in vb.net

 Imports System.Data.OleDb


Public Class Form1


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim strSql As String

        strSql = "Select * From TestData.dbf"

        Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\;Extended Properties=dBASE IV;")

        Dim cmd As OleDbCommand = New OleDbCommand(strSql, con)

        con.Open()

        Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)

        Dim myDataSet As DataSet = New DataSet()

        myDA.Fill(myDataSet, "MyT")

        Dgv.DataSource = myDataSet.Tables("MyT").DefaultView

        con.Close()

        con = Nothing

    End Sub

End Class

沒有留言:

張貼留言