Iam so green to VB that it just isnt funny.
I have read books and searchrd for 2 days now. The problem Im having is accesing a DBF file as database.
I tried using the "Add New Datasource" but I got nowhere. It seams that MS is looking for a file rather then a dirrectory which is where dbf files are recognised.
I have tried to code the connection my self and I have succeded in connecting and creating a dataset which I can then examine and change.
My problem is that I can save the changes back to the database. Im getting error
"Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information."
I dont know what to do. Key column isnt something that any of the tutorials mantioned and I obviously did not create the dbf file itself.
Here is my code
Expand|Select|Wrap|Line Numbers
- Imports System.Data
- Imports Microsoft.Data.ODBC
- Public Class Form1
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim vvvv As String
- Dim ds As New DataSet
- Dim da As OleDb.OleDbDataAdapter
- Dim sql As String
- Dim cb As OleDb.OleDbCommandBuilder
- Dim Conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\pricePPJ;Extended Properties=dBase IV;")
- conn.Open()
- sql = "SELECT * FROM RSD.cdx "
- da = New OleDb.OleDbDataAdapter(sql, Conn)
- cb = New OleDb.OleDbCommandBuilder(da)
- da.Fill(ds, "AddressBook")
- vvvv = ds.Tables("AddressBook").Rows(0).Item(58)
- ds.Tables("AddressBook").Rows(0).Item(58) = "Change"
- Stop
- da.Update(ds, "AddressBook")
- conn.Close()
- End Sub
- End Class
Im not particularly attached to this method, so if there is a better way I'll be glad to learn it. I like the dataset because it lets me navigate through the content but if I can do this directly then that will be ok as well.
Thank you for any help
Michal