|
-
Jan 10th, 2004, 07:38 AM
#1
Thread Starter
Lively Member
updating datasource???
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:
Private Sub BtnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEdit.Click
'variables
'make use of oledbcommandbuilder
Dim autogen As New OleDbCommandBuilder(DACD)
Dim datatable As DataTable
Dim row As DataRow
Dim strExpr As String
DataConnection.Open()
datatable = DSListboxes.Tables("tblCD")
'here I want to select the current CDID
strExpr = "CDID = " & Me.BindingContext(DSlistboxes, "tblCD").Position
'error message : value of 1-dimensional array of system.data.datarow cannot be converted to system.data.datarowview
row = datatable.Select(strExpr)
'Populate the datarow with values
row("ProgramGroup") = Me.TextBoxProgramGroup.Text
row("SubgroupID") = Me.ListBox3.SelectedValue
row("CompanyID") = Me.ListBoxCompany.SelectedValue
DACD.Update(DSlistboxes, "tblCD")
'close dataconnection
DataConnection.Close()
End Sub
Can anybody help me, or should I use other code??
thanx
tom
-
Jan 10th, 2004, 07:23 PM
#2
Hyperactive Member
change:
Dim row As DataRow
to
Dim row() As DataRow
and it should work as you need to declare the datarow as an array for the selec statement on the datatable.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|