I search a lot for this, it’s a little old, but if you needed, here it is the sample code:
Dim con As New OleDb.OleDbConnection
Dim com As New OleDb.OleDbCommand
con.ConnectionString = “Provider=vfpoledb.1;Data Source=dir.dbf;Collating Sequence=machine”
con.Open()
com.Connection = con
com.CommandText = “INSERT INTO dir (col1) VALUES (‘” & val1 & “‘)”
com.ExecuteNonQuery()
If you want a select, it is similar, replace the sql command.
And here is the code for creating a dbf file:
Dim dBaseConnection As New System.Data.OleDb.OleDbConnection(“Provider=Microsoft.Jet.OLEDB.4.0;” & _
“Data Source=” & path & “;” & _
“Extended Properties=dBase IV”)
dBaseConnection.Open()
‘New table
Dim SQLCreateCommand As String
SQLCreateCommand = “CREATE TABLE SUBDIR ” & _
“(subdir TEXT(50))”
Dim dBaseCommand As New System.Data.OleDb.OleDbCommand(SQLCreateCommand, dBaseConnection)
dBaseCommand.ExecuteNonQuery()
dBaseConnection.Close()
In the code above, path is the directory where you want to create the DBF file, it does not include the filename!
Update:
You can download Microsoft OLE DB Provider for Visual FoxPro 9.0 for the above code from
here.