Hi,

I'm having problems updating a row in a datatable (tblCD) from a dataset (DSlistboxes).

The table contains the following columns:
CDID = pk, autonumber
Programgroup = text
SubgroupID = number
CompanyID = number

The values must be updated by a winform that contains listboxes and a textbox where the user can edit the fields. The CDID is the current record in the datatable.

The difficult part is to select the current CDID in the datatable that must be edited. I do this by using the the bindingcontext of the dataset but I don't know if this is correct. There is also a problem with the definition of the row : I added the error message in the code (text)

I use the following code:

VB Code:
  1. Private Sub BtnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEdit.Click
  2.         'variables
  3.         'make use of oledbcommandbuilder
  4.         Dim autogen As New OleDbCommandBuilder(DACD)
  5.         Dim datatable As DataTable
  6.         Dim row As DataRow
  7.         Dim strExpr As String
  8.  
  9.         DataConnection.Open()
  10.         datatable = DSListboxes.Tables("tblCD")
  11.         'here I want to select the current CDID
  12.         strExpr = "CDID = " & Me.BindingContext(DSlistboxes, "tblCD").Position
  13.         'error message : value of 1-dimensional array of system.data.datarow cannot be converted to system.data.datarowview
  14.         row = datatable.Select(strExpr)
  15.         'Populate the datarow with values
  16.         row("ProgramGroup") = Me.TextBoxProgramGroup.Text
  17.         row("SubgroupID") = Me.ListBox3.SelectedValue
  18.         row("CompanyID") = Me.ListBoxCompany.SelectedValue
  19.      
  20.         DACD.Update(DSlistboxes, "tblCD")
  21.         'close dataconnection
  22.         DataConnection.Close()
  23.  
  24.  
  25.  
  26.          End Sub


Can anybody help me, or should I use other code??

thanx

tom