Personal Information System

 


Below are the features of personal information system
  • The system is capable of adding new records 
  • The system is capable of editing existing records 
  • The system is capable of deleting records 
  • The system is capable of viewing records 
Code snippet
Database connection

  Public Sub ConnectToDatabase()

        If cn.State = ConnectionState.Open Then cn.Close()
        With cn
            .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\database.mdb;"
            .Open()
        End With
    End Sub

Insert record
 Dim sql As String = "Insert into tblPersonal (lastname,middlename,firstname,dateofbirth,address) values('" & _

                            txtFname.Text & "','" & _
                            txtMname.Text & "','" & _
                            txtLname.Text & "','" & _
                            dtBdate.Text & "','" & _
                            txtAddress.Text & "')"
            cm = New OleDbCommand(sql, cn)
            cm.ExecuteNonQuery()
            MessageBox.Show("Record successfully saved.", "Eraser Software SOlution", MessageBoxButtons.OK, MessageBoxIcon.Information)
Update record
Dim sql1 As String = "Update tblPersonal set Firstname='" & txtFname.Text & _

                        "',Middlename='" & txtMname.Text & _
                        "',Lastname='" & txtLname.Text & _
                        "',Dateofbirth='" & dtBdate.Value & _
                        "',Address='" & txtAddress.Text & "' where ID like '" & txtID.Text & "'"
            cm = New OleDbCommand(sql1, cn)
            cm.ExecuteNonQuery()
            MessageBox.Show("Record successfully updated.", "Eraser Software SOlution", MessageBoxButtons.OK, MessageBoxIcon.Information)
Delete record
cm = New OleDbCommand("DELETE from tblPersonal where id like '" & ListView1.SelectedItems(0).SubItems(0).Text & "'", cn)
                cm.ExecuteNonQuery()   
                MsgBox("Record successfully deleted.", vbInformation)
View records
  Public Sub ViewRecord()
        ListView1.Items.Clear()
        Dim sql As String = "Select * from tblPersonal"
        cm = New OleDbCommand(sql, cn)
        dr = cm.ExecuteReader
        While (dr.Read())

            With ListView1.Items.Add(dr("ID"))
                .SubItems.Add(dr("firstname"))
                .SubItems.Add(dr("middlename"))
                .SubItems.Add(dr("lastname"))
                .SubItems.Add(dr("dateofbirth"))
                .SubItems.Add(dr("address"))
            End With
        End While
        dr.Close()
    End Sub