I have a class that creates a dataset and dataadapter.
When the user updates a Windows form, I want the dataadapter to update the DB of course. The code runs without an error , but the database does not get updated.
here is where the Dataadapter is created:
Code:
Me.EmployeeDA = New SqlDataAdapter("SelectedEmployee",
connection)
'Dim SELECTED As New DataSet
With EmployeeDA
.TableMappings.Add("Employees", "SelectedEmployee")
.MissingSchemaAction = MissingSchemaAction.AddWithKey
.SelectCommand.CommandType = CommandType.StoredProcedure
.SelectCommand.Parameters.Add("@LastName", empLname)
.SelectCommand.Parameters.Add("@FirstName", empFname)
.FillSchema(SELECTED, SchemaType.Source)
.Fill(SELECTED)
End With
no errors there and the dataset gets filled with exactly one row as it should.
Ok, edit the current data in the dataset
Code:
Dim drCurrent As DataRow
drCurrent = oEmployee.SELECTED.Tables(0).Rows.Find(empID)
drCurrent.BeginEdit()
drCurrent("Title") = oEmployee.Title
drcurrent.EndEdit()
OK , send the changes back to the Database
Code:
oEmployee.EmployeeDA.Update(oEmployee.SELECTED)
this all runs without error, but the database does not update.
is this code correct, or am i missing something?