G
Guest
Using VB.Net, Framework 1.0, Jet 4.0. Two ComboBoxes (prefixed "cbo") and
three DateTimePickers (prefixed "dtp") are bound to a DataSet (m_DS)
populated from four hierarchical tables: Company, which is the parent of
Invoice, which is the parent of both Expense and Timesheet. These are the
bindings:
With cboCompany
.DataSource = m_DS.Tables("Company")
.DisplayMember = "Name"
.ValueMember = "IDNum"
If .DataBindings.Count = 0 Then
.DataBindings.Add("SelectedValue", m_DS, "Company.IDNum")
End If
End With
With cboInvoiceNum
.DataSource = m_DS.Tables("Invoice")
.DisplayMember = "InvoiceNum"
.ValueMember = "IDNum"
If .DataBindings.Count = 0 Then
.DataBindings.Add("SelectedValue", m_DS, "Invoice.IDNum")
End If
End With
With dtpInvoiceDate
If .DataBindings.Count = 0 Then
.DataBindings.Add("Text", m_DS, "Invoice.InvoiceDate")
End If
End With
With dtpFrom
If .DataBindings.Count = 0 Then
.DataBindings.Add("Text", m_DS, "Invoice.FromDate")
End If
End With
With dtpThrough
If .DataBindings.Count = 0 Then
.DataBindings.Add("Text", m_DS, "Invoice.ThroughDate")
End If
End With
A "New" button calls
Me.BindingContext(m_DS, "Invoice").AddNew()
and sets cboInvoiceNum, dtpInvoiceDate, dtpFrom, and dtpThrough.
A "Save" button calls
Dim cm As CurrencyManager = _
CType(Me.BindingContext(m_DS, "Invoice"), CurrencyManager)
cm.EndCurrentEdit()
If Me.m_DS.HasChanges Then
Dim ds As DataSet = Me.m_DS.GetChanges()
If Not ds.HasErrors() Then
Me.m_daInvoice.Update(ds, "Invoice")
Me.m_DS.AcceptChanges()
End If
End If
The new record is inserted in the database, but only the IDNum (an
AutoNumber) and the FromDate columns are populated. Why not the others? Any
help would be greatly appreciated.
three DateTimePickers (prefixed "dtp") are bound to a DataSet (m_DS)
populated from four hierarchical tables: Company, which is the parent of
Invoice, which is the parent of both Expense and Timesheet. These are the
bindings:
With cboCompany
.DataSource = m_DS.Tables("Company")
.DisplayMember = "Name"
.ValueMember = "IDNum"
If .DataBindings.Count = 0 Then
.DataBindings.Add("SelectedValue", m_DS, "Company.IDNum")
End If
End With
With cboInvoiceNum
.DataSource = m_DS.Tables("Invoice")
.DisplayMember = "InvoiceNum"
.ValueMember = "IDNum"
If .DataBindings.Count = 0 Then
.DataBindings.Add("SelectedValue", m_DS, "Invoice.IDNum")
End If
End With
With dtpInvoiceDate
If .DataBindings.Count = 0 Then
.DataBindings.Add("Text", m_DS, "Invoice.InvoiceDate")
End If
End With
With dtpFrom
If .DataBindings.Count = 0 Then
.DataBindings.Add("Text", m_DS, "Invoice.FromDate")
End If
End With
With dtpThrough
If .DataBindings.Count = 0 Then
.DataBindings.Add("Text", m_DS, "Invoice.ThroughDate")
End If
End With
A "New" button calls
Me.BindingContext(m_DS, "Invoice").AddNew()
and sets cboInvoiceNum, dtpInvoiceDate, dtpFrom, and dtpThrough.
A "Save" button calls
Dim cm As CurrencyManager = _
CType(Me.BindingContext(m_DS, "Invoice"), CurrencyManager)
cm.EndCurrentEdit()
If Me.m_DS.HasChanges Then
Dim ds As DataSet = Me.m_DS.GetChanges()
If Not ds.HasErrors() Then
Me.m_daInvoice.Update(ds, "Invoice")
Me.m_DS.AcceptChanges()
End If
End If
The new record is inserted in the database, but only the IDNum (an
AutoNumber) and the FromDate columns are populated. Why not the others? Any
help would be greatly appreciated.