M
Markus
My code at btnDelete doesn't work. Can you help?
And I'm new to all this programming stuff but 'm
learning
Public Class frmSuradnici
Inherits System.Windows.Forms.Form
Dim objConnection As New OleDb.OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\Surgery.mdb")
Dim objOwnerDA As New OleDb.OleDbDataAdapter("Select *
from Owners", _
objConnection)
Dim objOwnerCB As New OleDb.OleDbCommandBuilder
(objOwnerDA)
Dim objDataSet As New DataSet()
Windows Form Generated Code
Private Sub btnRetrieve_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnRetrieve.Click
objDataSet.Clear()
objOwnerDA.FillSchema(objDataSet,
SchemaType.Source, "Owners")
objOwnerDA.Fill(objDataSet, "Owners")
cboOwners.Items.Clear()
Dim i As Integer, strCurrentID As String
For i = 1 To objDataSet.Tables("Owners").Rows.Count
strCurrentID = objDataSet.Tables("Owners").Rows
(i - 1).Item("OwnerID")
cboOwners.Items.Add(strCurrentID)
Next
cboOwners.SelectedIndex = 0
FillOwnerDetails()
End Sub
Public Sub FillOwnerDetails()
Dim objRow As DataRow
objRow = objDataSet.Tables("Owners").Rows.Find
(cboOwners.SelectedItem.ToString)
lblOwnerID.Text = objRow.Item("OwnerID")
txtName.Text = objRow.Item("Name")
txtAddress.Text = objRow.Item("Address")
End Sub
Public Sub StoreOwnerDetails()
Dim objRow As DataRow
If lblOwnerID.Text = "" Then Exit Sub
objRow = objDataSet.Tables("Owners").Rows.Find
(lblOwnerID.Text)
objRow.Item("Name") = txtName.Text
objRow.Item("Address") = txtAddress.Text
End Sub
Private Sub cboOwners_SelectedIndexChanged(ByVal
sender As Object, ByVal e As System.EventArgs) Handles
cboOwners.SelectedIndexChanged
StoreOwnerDetails()
FillOwnerDetails()
End Sub
Private Sub btnSave_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnSave.Click
StoreOwnerDetails()
objOwnerDA.Update(objDataSet, "Owners")
End Sub
Private Sub frmSuradnici_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Dim toolTip1 As New ToolTip
toolTip1.AutoPopDelay = 5000
toolTip1.InitialDelay = 1000
toolTip1.ReshowDelay = 500
toolTip1.ShowAlways = True
toolTip1.SetToolTip(Me.cboOwners, "Izaberite
suradnički broj kako bi dobili njegove podatke.")
toolTip1.SetToolTip(Me.lblOwnerID, "Suradnički
broj")
toolTip1.SetToolTip(Me.txtName, "Pogledajte /
Upisite ime i prezime suradnika.")
toolTip1.SetToolTip(Me.txtAddress, "Pogledajte /
Upisite adresu suradnika.")
toolTip1.SetToolTip(Me.btnRetrieve, "Učitajte
podatke o suradnicima iz baze.")
toolTip1.SetToolTip(Me.btnSave, "Pohranite
promjene u bazu.")
toolTip1.SetToolTip(Me.Label1, "Programer:
Tomislav Ivančić.")
toolTip1.SetToolTip(Me, "FIDELITAS d.o.o.")
End Sub
Private Sub btnDelete_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnDelete.Click
Dim objRow As DataRow
objRow = objDataSet.Tables("Owners").Rows.Find
("OwnerID")
objRow.Delete()
End Sub
End Class
And I'm new to all this programming stuff but 'm
learning
Public Class frmSuradnici
Inherits System.Windows.Forms.Form
Dim objConnection As New OleDb.OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\Surgery.mdb")
Dim objOwnerDA As New OleDb.OleDbDataAdapter("Select *
from Owners", _
objConnection)
Dim objOwnerCB As New OleDb.OleDbCommandBuilder
(objOwnerDA)
Dim objDataSet As New DataSet()
Windows Form Generated Code
Private Sub btnRetrieve_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnRetrieve.Click
objDataSet.Clear()
objOwnerDA.FillSchema(objDataSet,
SchemaType.Source, "Owners")
objOwnerDA.Fill(objDataSet, "Owners")
cboOwners.Items.Clear()
Dim i As Integer, strCurrentID As String
For i = 1 To objDataSet.Tables("Owners").Rows.Count
strCurrentID = objDataSet.Tables("Owners").Rows
(i - 1).Item("OwnerID")
cboOwners.Items.Add(strCurrentID)
Next
cboOwners.SelectedIndex = 0
FillOwnerDetails()
End Sub
Public Sub FillOwnerDetails()
Dim objRow As DataRow
objRow = objDataSet.Tables("Owners").Rows.Find
(cboOwners.SelectedItem.ToString)
lblOwnerID.Text = objRow.Item("OwnerID")
txtName.Text = objRow.Item("Name")
txtAddress.Text = objRow.Item("Address")
End Sub
Public Sub StoreOwnerDetails()
Dim objRow As DataRow
If lblOwnerID.Text = "" Then Exit Sub
objRow = objDataSet.Tables("Owners").Rows.Find
(lblOwnerID.Text)
objRow.Item("Name") = txtName.Text
objRow.Item("Address") = txtAddress.Text
End Sub
Private Sub cboOwners_SelectedIndexChanged(ByVal
sender As Object, ByVal e As System.EventArgs) Handles
cboOwners.SelectedIndexChanged
StoreOwnerDetails()
FillOwnerDetails()
End Sub
Private Sub btnSave_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnSave.Click
StoreOwnerDetails()
objOwnerDA.Update(objDataSet, "Owners")
End Sub
Private Sub frmSuradnici_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Dim toolTip1 As New ToolTip
toolTip1.AutoPopDelay = 5000
toolTip1.InitialDelay = 1000
toolTip1.ReshowDelay = 500
toolTip1.ShowAlways = True
toolTip1.SetToolTip(Me.cboOwners, "Izaberite
suradnički broj kako bi dobili njegove podatke.")
toolTip1.SetToolTip(Me.lblOwnerID, "Suradnički
broj")
toolTip1.SetToolTip(Me.txtName, "Pogledajte /
Upisite ime i prezime suradnika.")
toolTip1.SetToolTip(Me.txtAddress, "Pogledajte /
Upisite adresu suradnika.")
toolTip1.SetToolTip(Me.btnRetrieve, "Učitajte
podatke o suradnicima iz baze.")
toolTip1.SetToolTip(Me.btnSave, "Pohranite
promjene u bazu.")
toolTip1.SetToolTip(Me.Label1, "Programer:
Tomislav Ivančić.")
toolTip1.SetToolTip(Me, "FIDELITAS d.o.o.")
End Sub
Private Sub btnDelete_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnDelete.Click
Dim objRow As DataRow
objRow = objDataSet.Tables("Owners").Rows.Find
("OwnerID")
objRow.Delete()
End Sub
End Class