I have a problem when I need to add a column to table with dbf format this is the code of adding column button event:
Try
Form1.FillDataGridView("ALTER TABLE MyDBase ADD COLUMN ZipCode TEXT(10)")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, Text)
End Try
error message: operation not allowed for that type of object
and this is the code to load dbf file in DataGridView:
'OPEN CONNECTION TO dbf file
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Users\tunes\Documents\;Extended Properties=dBase IV"
cn.Open()
'Load file from dbf into DataGridView1
FillDataGridView("select * from MyDBase ")
and finally FillDataGridView function:
da = New OleDbDataAdapter(Query, cn)
dt.Clear()
da.Fill(dt)
With DataGridView1
.DataSource = dt
End With
Have you tried downloading and using the Microsoft Visual Foxpro OleDB Provider.
Your connection string would need to be simplified down a bit to...
"Provider=VFPOLEDB.1;Data Source=C:\PathOnly\ToWhere\TheDataFilesExist\;"
Maybe its the "jet" engine driver that can not properly alter the table structure.