I have a mmPicker on my WinForm configured as follows:
VisitorCompanyNamePicker
BindingSource: Company
BindingSourceMember: CompanyName
BindingValueSource: Visitor
BindingValueSourceMember: CompanyName
DataCommand: SELECT CompanyName FROM Companies Order By CompanyName
GridColumns: VisitorCompanyColumn (BindingSourceMember = CompanyName)
PickListDisplayMember: CompanyName
PicListSearchField: CompanyName
PickListValueMember: CompanyName
I can use this control successfully to update existing records, but get the following error each time I use the control to assign a value to a new record:
Cannot insert the value NULL into column 'CompanyName', table 'StellarVisiTrakProd.dbo.Visitors'; column does not allow nulls. INSERT fails.
The statement has been terminated.
My Form Methods for New and Save are as follows:
Private Sub VisitorNewButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VisitorNewButton.Click
Me.oVisitor.NewRow _
(New VisitorDefaultValues _
(DateTime.Now, _
System.Security.Principal.WindowsIdentity.GetCurrent.Name.ToString))
Me.BindingContext(Me.oVisitor.GetCurrentDataSet(), "Visitors").Position = _
Me.oVisitor.GetCurrentDataSet().Tables("Visitors").Rows.Count - 1
End Sub
Private Sub VisitorSaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VisitorSaveButton.Click
If Me.oVisitor.IsChanged = True Then
Dim result As mmSaveDataResult = _
Me.oVisitor.SaveDataSet(Me.oVisitor.GetCurrentDataSet())
Else
MsgBox("No changes made to Visitors")
End If
End Sub
THANKS
Joe Salvatore, Programmer/Analyst - The Stellar Group