N
Newbie!
Hi Group,
Hope someone wouldn`t mind advising on a bit of Code i`ve wrote. Could
someone tell me does this look right and advise me of problems or
suggestions - before I start duplicating it across my project?
Private Sub frmContracts_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'AutoLoads and Pupulates the Dataset
If odcContracts.State <> ConnectionState.Open Then odcContracts.Open()
odaContracts.Fill(dsContracts)
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancel.Click
'Closes the Database and Exits to frmMain
If odcContracts.State <> ConnectionState.Closed Then
odcContracts.Close()
Me.Close()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
'Deletes Selected Colum
If (Me.BindingContext(dsContracts, "ContractProviders").Count > 0)
Then
Me.BindingContext(dsContracts,
"ContractProviders").RemoveAt(Me.BindingContext(dsContracts,
"ContractProviders").Position)
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
'Adds a new Colum
Me.BindingContext(dsContracts, "ContractProviders").EndCurrentEdit()
Me.BindingContext(dsContracts, "ContractProviders").AddNew()
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
'Updates All Changes to DATAGRID - Also Displays Confirmation
Dim RecordsUpdate As Integer
If dsContracts.HasChanges Then
RecordsUpdate = odaContracts.Update(dsContracts)
MessageBox.Show(RecordsUpdate.ToString & " Contract Record(s)
Updated.")
Else
MessageBox.Show("There Are No Changed Records to Update.")
End If
End Sub
Many Thanks and Best Regards
Si
Hope someone wouldn`t mind advising on a bit of Code i`ve wrote. Could
someone tell me does this look right and advise me of problems or
suggestions - before I start duplicating it across my project?
Private Sub frmContracts_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'AutoLoads and Pupulates the Dataset
If odcContracts.State <> ConnectionState.Open Then odcContracts.Open()
odaContracts.Fill(dsContracts)
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancel.Click
'Closes the Database and Exits to frmMain
If odcContracts.State <> ConnectionState.Closed Then
odcContracts.Close()
Me.Close()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
'Deletes Selected Colum
If (Me.BindingContext(dsContracts, "ContractProviders").Count > 0)
Then
Me.BindingContext(dsContracts,
"ContractProviders").RemoveAt(Me.BindingContext(dsContracts,
"ContractProviders").Position)
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
'Adds a new Colum
Me.BindingContext(dsContracts, "ContractProviders").EndCurrentEdit()
Me.BindingContext(dsContracts, "ContractProviders").AddNew()
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
'Updates All Changes to DATAGRID - Also Displays Confirmation
Dim RecordsUpdate As Integer
If dsContracts.HasChanges Then
RecordsUpdate = odaContracts.Update(dsContracts)
MessageBox.Show(RecordsUpdate.ToString & " Contract Record(s)
Updated.")
Else
MessageBox.Show("There Are No Changed Records to Update.")
End If
End Sub
Many Thanks and Best Regards
Si