Hey Group,
Please bare with me ehile I try and explain, i think i maybe on the wrong
track but this is driving me crazy now:(
I have the following code:
Private Sub frmMainMenuPasswords_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
odcPasswordLists.ConnectionString = Connection.String
cmDsPasswordList = BindingContext(dsPasswordList, "PasswordList")
mlLoading = True
'Start of Fill Datasets
Try
dsPasswordList.EnforceConstraints = False
Try
Me.odcPasswordLists.Open()
'Fill Password Lists Datasets
Me.odaDepartments.Fill(dsPasswordList)
Me.odaPasswordList.Fill(dsPasswordList)
Catch fillException As System.Exception
Throw fillException
Finally
'To be enabled if Dataset Bindings Fail - Enabling will
cause BIG Datasets
'dsPasswordList.EnforceConstraints = True
Me.odcPasswordLists.Close()
End Try
Catch eLoad As System.Exception
System.Windows.Forms.MessageBox.Show(eLoad.Message )
Finally
mlLoading = False
End Try
'End of Fill Datasets
End Sub
'Start of Position Changed Code - Password Lists
Private Sub cmDsPasswordList_PositionChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles cmDsPasswordList.PositionChanged
DsPasswordList_PositionChanged()
End Sub
Private Sub cboPasswordListsDepartment_SelectedIndexChanged(By Val sender
As Object, ByVal e As System.EventArgs) Handles
cboPasswordListsDepartment.SelectedIndexChanged
Me.BindingContext(dsPasswordList, "PasswordList").EndCurrentEdit()
If Me.BindingContext(dsPasswordList, "PasswordList").Position <> -1
And Not mlLoading Then
dsPasswordList.PasswordList.Rows(Me.BindingContext (dsPasswordList,
"PasswordList").Position).Item("DepartmentID") =
Me.cboPasswordListsDepartment.SelectedValue
End If
End Sub
Private Sub DsPasswordList_PositionChanged()
Me.BindingContext(dsPasswordList, "PasswordList").EndCurrentEdit()
If Me.BindingContext(dsPasswordList, "PasswordList").Position <> -1
And Not mlLoading Then
Me.cboPasswordListsDepartment.SelectedValue =
dsPasswordList.PasswordList.Rows(Me.BindingContext (dsPasswordList,
"PasswordList").Position).Item("DepartmentID")
End If
End Sub
'End of Position Changed Code - Password Lists
'PasswordLists Code Start
Private Sub btnPasswordListsDelete_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnPasswordListsDelete.Click
If MessageBox.Show("Are Your Sure You Want To Delete?",
"WARNING!!!!", MessageBoxButtons.OKCancel) = DialogResult.OK Then
If (Me.BindingContext(dsPasswordList, "PasswordList").Count > 0)
Then
Me.BindingContext(dsPasswordList,
"PasswordList").RemoveAt(Me.BindingContext(dsPassw ordList,
"PasswordList").Position)
End If
End If
End Sub
Private Sub btnPasswordListsAdd_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnPasswordListsAdd.Click
'Reset Combo Box`s - Select Index Twice due to M$ Bug
cboPasswordListsDepartment.Text = ""
cboPasswordListsDepartment.SelectedIndex = -1
cboPasswordListsDepartment.SelectedIndex = -1
txtPasswordListsAccessLevel.Enabled = True
txtPasswordListsID.Enabled = True
txtPasswordListsNotes.Enabled = True
txtPasswordListsPassword.Enabled = True
txtPasswordListsPrimaryUse.Enabled = True
txtPasswordListsPrimaryUser.Enabled = True
txtPasswordListsSystem.Enabled = True
txtPasswordListsUsername.Enabled = True
txtPasswordListsWebAddress.Enabled = True
dtpPasswordLists.Enabled = True
cboPasswordListsDepartment.Enabled = True
Try
Me.BindingContext(dsPasswordList,
"PasswordList").EndCurrentEdit()
Me.BindingContext(dsPasswordList, "PasswordList").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Mess age)
End Try
End Sub
Private Sub btnPasswordListsCancel_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnPasswordListsCancel.Click
Me.BindingContext(dsPasswordList,
"PasswordList").CancelCurrentEdit()
txtPasswordListsAccessLevel.Enabled = False
txtPasswordListsID.Enabled = False
txtPasswordListsNotes.Enabled = False
txtPasswordListsPassword.Enabled = False
txtPasswordListsPrimaryUse.Enabled = False
txtPasswordListsPrimaryUser.Enabled = False
txtPasswordListsSystem.Enabled = False
txtPasswordListsUsername.Enabled = False
txtPasswordListsWebAddress.Enabled = False
dtpPasswordLists.Enabled = False
cboPasswordListsDepartment.Enabled = False
End Sub
Private Sub btnPasswordListsUpdate_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnPasswordListsUpdate.Click
If MessageBox.Show("Are Your Sure You Want To Save Changes?",
"WARNING!!!!", MessageBoxButtons.OKCancel) = DialogResult.OK Then
Try
Dim objDataSetChanges As Excellence.NET.dsPasswordList = New
Excellence.NET.dsPasswordList()
Me.BindingContext(dsPasswordList,
"PasswordList").EndCurrentEdit()
objDataSetChanges = CType(dsPasswordList.GetChanges,
Excellence.NET.dsPasswordList)
If (Not (objDataSetChanges) Is Nothing) Then
Try
If (Not (dsPasswordList) Is Nothing) Then
Me.odcPasswordLists.Open()
odaDepartments.Update(dsPasswordList)
odaPasswordList.Update(dsPasswordList)
End If
Catch updateException As System.Exception
Throw updateException
Finally
Me.odcPasswordLists.Close()
End Try
End If
dsPasswordList.Merge(objDataSetChanges)
dsPasswordList.AcceptChanges()
Catch eUpdate As System.Exception
System.Windows.Forms.MessageBox.Show(eUpdate.Messa ge)
End Try
txtPasswordListsAccessLevel.Enabled = False
txtPasswordListsID.Enabled = False
txtPasswordListsNotes.Enabled = False
txtPasswordListsPassword.Enabled = False
txtPasswordListsPrimaryUse.Enabled = False
txtPasswordListsPrimaryUser.Enabled = False
txtPasswordListsSystem.Enabled = False
txtPasswordListsUsername.Enabled = False
txtPasswordListsWebAddress.Enabled = False
dtpPasswordLists.Enabled = False
cboPasswordListsDepartment.Enabled = False
End If
End Sub
Private Sub btnPasswordListsEdit_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnPasswordListsEdit.Click
txtPasswordListsAccessLevel.Enabled = True
txtPasswordListsID.Enabled = True
txtPasswordListsNotes.Enabled = True
txtPasswordListsPassword.Enabled = True
txtPasswordListsPrimaryUse.Enabled = True
txtPasswordListsPrimaryUser.Enabled = True
txtPasswordListsSystem.Enabled = True
txtPasswordListsUsername.Enabled = True
txtPasswordListsWebAddress.Enabled = True
dtpPasswordLists.Enabled = True
cboPasswordListsDepartment.Enabled = True
End Sub
'PasswordLists Code Finish
When I try to run my Add code it errors on:
dsPasswordList.PasswordList.Rows(Me.BindingContext (dsPasswordList,
"PasswordList").Position).Item("DepartmentID") =
Me.cboPasswordListsDepartment.SelectedValue
And tells me it cannot user NULL and to use DBNULL instead so i put:
dsPasswordList.PasswordList.Rows(Me.BindingContext (dsPasswordList,
"PasswordList").Position).Item("DepartmentID") =
Me.cboPasswordListsDepartment.SelectedValue = system.DBNULL.value - but it
fails to compile and tells me:
D:\Excellence.Net\MainMenuPasswords.vb(1390): Operator '=' is not defined
for types 'System.Object' and 'System.DBNull'. Use 'Is' operator to compare
two reference types.
If I remove the following code from my project:
'Reset Combo Box`s - Select Index Twice due to M$ Bug
cboPasswordListsDepartment.Text = ""
cboPasswordListsDepartment.SelectedIndex = -1
cboPasswordListsDepartment.SelectedIndex = -1
It lets me add a row but then gives me a Concurrency Violation When I run my
Update Code.
Anybody got any Ideas?
Many Thanks and Sorry for the long Post
Regards
MCN