Hello,
I am having trouble with my OleDbCommandBuilder updating my datatable.
my code is as follows
The comboboxes cbOpNo and cbStage are populated by the following code, which is triggered on a selected index change
when the lines
run i get the error Missing the DataColumn 'Description' in the DataTable 'BM401600 6055' for the SourceColumn 'Description'.
The column it is referring to is in the datatable "OpRoute"
if i set
The data table is updated no problems
How can i get it to work as i want but without it trying to add to a column that isn't in that datatable(myDGV)
Thanks for any advice, this has been giving me a headache all day!
I am having trouble with my OleDbCommandBuilder updating my datatable.
my code is as follows
VB.NET:
Dim DateAch As String = Date.Now.ToString("dd/MM/yyyy")
Dim Competence As Integer = cbComp.SelectedValue
Dim OpNo As String = cbOpNo.SelectedValue
Dim Ustage As String = cbStage.SelectedValue
Dim findtab As String
Dim findTC As TabControl
Dim myDGV As String
For Each Ctrl As Control In tcTest.SelectedTab.Controls
If TypeOf Ctrl Is TabControl Then
findTC = Ctrl
findtab = findTC.SelectedTab.Name
myDGV = "" & findtab & " " & EmpNumber & ""
Dim NewRow As DataRow = ds.Tables("" & findtab & " " & EmpNumber & "").NewRow()
ds.Tables(myDGV).Rows.Add(NewRow)
NewRow.Item("EmpNo") = EmpNumber
NewRow.Item("Prod") = tcTest.SelectedTab.Name
NewRow.Item("SubAssy") = findtab
NewRow.Item("OpNo") = cbOpNo.SelectedValue.
NewRow.Item("Competence") = Competence
NewRow.Item("DateAchieved") = DateAch
NewRow.Item("Stage") = cbStage.SelectedValue
Dim my_builder As OleDbCommandBuilder = New OleDbCommandBuilder(da)
my_builder.GetUpdateCommand()
da.Update(ds.Tables(myDGV))
End If
Next
The comboboxes cbOpNo and cbStage are populated by the following code, which is triggered on a selected index change
VB.NET:
Dim mytabcon As New TabControl mytabcon = Sender
sql = " Select * From " & mytabcon.SelectedTab.Name & ""
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "OpRoute")
dgOpDesc.DataSource = ds.Tables("OpRoute")
dgOpDesc.AutoResizeColumns()
cbOpNo.ValueMember = ("OpNo")
cbOpNo.DisplayMember = ("OpNo")
cbOpNo.DataSource = ds.Tables("OpRoute")
cbStage.ValueMember = ("Stage")
cbStage.DisplayMember = ("Stage")
cbStage.DataSource = ds.Tables("OpRoute")
when the lines
VB.NET:
Dim my_builder As OleDbCommandBuilder = New OleDbCommandBuilder(da)
my_builder.GetUpdateCommand()
da.Update(ds.Tables(myDGV))
run i get the error Missing the DataColumn 'Description' in the DataTable 'BM401600 6055' for the SourceColumn 'Description'.
The column it is referring to is in the datatable "OpRoute"
if i set
VB.NET:
NewRow.Item("OpNo") = TextBox1.text
NewRow.Item("Stage") = TextBox2.text
How can i get it to work as i want but without it trying to add to a column that isn't in that datatable(myDGV)
Thanks for any advice, this has been giving me a headache all day!