Hi,
I have a problem with updating my database with this code.
VB Code:
Private Sub DataUpdate()
Dim oAdapter As OleDbDataAdapter
Dim oBuild As OleDbCommandBuilder
Dim oDR As DataRow
Dim strSQL As String
Dim strID As String
Dim strConn As String
' Get Primary Key From List Box
strID = CType(lstLeden.SelectedItem, PDSAListItemNumeric).ID.ToString()
' Find Row To Update
oDR = moDS.Tables("Gegevens").Rows.Find(CInt(strID))
' Begin the editing process
oDR.BeginEdit()
' Load new data into row
oDR("Voorletters") = txtVoorletters.Text
oDR("Tussenvoegsel") = txtTussenvoegsel.Text
oDR("Achternaam") = txtAchternaam.Text
oDR("Aanspreeknaam") = txtAanspreeknaam.Text
oDR("Geslacht") = txtGeslacht.Text
oDR("Adres") = txtAdres.Text
oDR("Postcode") = txtPostcode.Text
' End the editing process
oDR.EndEdit()
Try
' Get Connection String
strConn = ConnectionString()
' Build SQL String
strSQL = "SELECT *, Achternaam + ', ' + Voorletters AS FullName FROM Gegevens"
' Create New DataAdapter
oAdapter = New OleDbDataAdapter(strSQL, strConn)
' Create CommandBuild from Adapter
' This will build INSERT, UPDATE and DELETE SQL
oBuild = New OleDbCommandBuilder(oAdapter)
' Get Update Command Object
oAdapter.UpdateCommand = oBuild.GetUpdateCommand()
' Submit UPDATE through Adapter
oAdapter.Update(moDS, "Gegevens")
' Tell DataSet changes to data source are complete
moDS.AcceptChanges()
' Reload the list box
ListLoad()
Catch oException As Exception
MessageBox.Show(oException.Message)
End Try
End Sub
When i run this piece of code it says that "Automatically Generate an SQL Statement is not supported"
Why is that, and what can i do about it?