Visual Basic .NET - ODBC Database

Using a ODBC database generated by Microsoft Access. Ability to read and write to the file/database.

Table

minecraft_mob
mID mName mAbout mImage mAvatar mEvil mBreed mTame mDateCreated mHearts
1 Chicken Drops feathers and raw chicken. Chicken ChickenFace 0 1 0 2013-12-08 4
2 Cow Drops leather and raw beef. Cow CowFace 0 1 0 2013-12-08 5
3 Pig Drops raw porkchops. Pig PigFace 0 1 0 2013-12-08 5
4 Creeper Explodes when player gets to close. Drops gun powder. Zzzzzz Creeper CreeperFace 1 0 0 2013-12-08 20
5 Skeleton Shoots arrows at players. Drops bones and bows. Skeleton SkeletonFace 1 0 0 2013-12-08 10
6 Ocelot Afraid of players but will only come close to player if player has fish in their hands. Ocelot OcelotFace 0 0 1 2013-12-08 5
7 Slime Multiplies when hit. Drops slime balls. Slime SlimeFace 1 0 0 2013-12-08 8
8 Wolf Hostile if attacked. Can be tamed by feeding bones. Wolf WolfFace 1 1 1 2013-12-08 4
9 Squid Drops ink sacks. Squid SquidFace 0 0 0 2013-12-08 5
10 Spider Attacks players at night or under shade. Spider SpiderFace 1 0 0 2013-12-08 8
11 Sheep Drops wool when sheared or killed. Sheep SheepFace 0 1 0 2013-12-09 5
12 Villager Spawns in villages and trades values with players. Villagers Villagerhead 0 1 0 2013-12-09 10
13 Enderman Will attack players if hit or looked at in the eyes. Enderman EndermanFace 1 0 0 2013-12-09 20
14 Ghast When a player is close, Ghast will shoot fire balls. Drops Ghast tears will killed. Ghast GhastFace 1 0 0 2013-12-09 10
15 Ender Dragon The final boss. Drops Ender Egg when killed. Spawn portal on defeat. EnderdragonFlying Enderdragon_Face 1 0 0 2013-12-09 100
16 Zombie Zombies will attack nearby players. Zombie ZombieFace 1 0 0 2013-12-09 10
17 Snow Golem Can be spawned by players Snow_Golem Snowgolemhead 1 0 0 2013-12-24 15
18 Wither I have no idea what a Wither is. Wither Wither_face 1 0 0 2013-12-29 50

Filling Data

    Private Sub FillMobDataSet()
        Try
            mobDataSet.Clear()
            mobDataAdapter.SelectCommand.CommandText = "SELECT * FROM " & conTableName
            mobDataAdapter.Fill(mobDataSet)
            FillControlsWithData()
        Catch ex As OleDbException
            MessageBox.Show(ex.Message)
        End Try
    End Sub
    Private Sub FillControlsWithData()
        Try
            mobDataTable = mobDataSet.Tables(0)

            If mobDataTable.Rows.Count <> 0 Then
                IDTextBox.Text = mobDataTable.Rows(intCurrentRow)(0)
                MonsterNameTextBox.Text = mobDataTable.Rows(intCurrentRow)(1)
                AboutTextbox.Text = mobDataTable.Rows(intCurrentRow)(2)
                ImageTextBox.Text = mobDataTable.Rows(intCurrentRow)(3)
                AvatarTextBox.Text = mobDataTable.Rows(intCurrentRow)(4)
                EvilCheckBox.Checked = mobDataTable.Rows(intCurrentRow)(5)
                BreedCheckBox.Checked = mobDataTable.Rows(intCurrentRow)(6)
                TameCheckBox.Checked = mobDataTable.Rows(intCurrentRow)(7)
                DateTimePicker.Value = mobDataTable.Rows(intCurrentRow)(8)
                HeartsUpDown.Value = mobDataTable.Rows(intCurrentRow)(9)
                AvatarPictureBox.Image = My.Resources.ResourceManager.GetObject(AvatarTextBox.Text)
                ImagePictureBox.Image = My.Resources.ResourceManager.GetObject(ImageTextBox.Text)
                RecordLabel.Text = "Record " & intCurrentRow + 1 & " of " & mobDataTable.Rows.Count
            End If

        Catch ex As OleDbException
            MessageBox.Show(ex.Message)
        End Try
    End Sub

Buttons

Next Button to view next row in table.

    Private Sub NextButton_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NextButton.Click
        Try
            If mobDataTable.Rows.Count - 1 <> intCurrentRow And SaveUpdatesToTable() Then
                SaveUpdatesToTable()
                intCurrentRow += 1
                FillMobDataSet()
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

Previous Button to view previous row in table.

    Private Sub PreviousButton_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreviousButton.Click
        Try
            If intCurrentRow > 0 And SaveUpdatesToTable() Then
                SaveUpdatesToTable()
                intCurrentRow = intCurrentRow - 1
                FillMobDataSet()
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

Reset Button which clears the fields.

    Private Sub ResetControls()
        IDTextBox.Text = intCurrentRow
        MonsterNameTextBox.Text = String.Empty
        AboutTextBox.Text = String.Empty
        ImageTextBox.Text = String.Empty
        AvatarTextBox.Text = String.Empty
        EvilCheckBox.Checked = 0
        BreedCheckBox.Checked = 0
        TameCheckBox.Checked = 0
        DateTimePicker.Value = DateTime.Now
        HeartsUpDown.Value = 0
        AvatarPictureBox.Image = My.Resources.ResourceManager.GetObject("newimage")
        ImagePictureBox.Image = My.Resources.ResourceManager.GetObject("none")
    End Sub

Save Information

When information has been changed or added, SaveUpdatesToTable() will get called.

    Private Function SaveUpdatesToTable() As Boolean
        Try
            mobDataAdapter.UpdateCommand.CommandText = _
                  "UPDATE " & conTableName & _
                  " SET mName = '" & CStr(MonsterNameTextBox.Text) & _
                  "', mAbout = '" & CStr(AboutTextBox.Text) & _
                  "', mImage = '" & CStr(ImageTextBox.Text) & _
                  "', mAvatar = '" & CStr(AvatarTextBox.Text) & _
                  "', mEvil = '" & IIf(EvilCheckBox.CheckState, "1", "0") & _
                  "', mBreed = '" & IIf(BreedCheckBox.CheckState, "1", "0") & _
                  "', mTame = '" & IIf(TameCheckBox.CheckState, "1", "0") & _
                  "', mDateCreated = '" & DateTimePicker.Value.Date & _
                  "', mHearts = " & CInt(HeartsUpDown.Value) & _
                  " WHERE mID = " & CInt(IDTextBox.Text)
            mobDataAdapter.UpdateCommand.ExecuteNonQuery()
            FillMobDataSet()
            Return (True)
        Catch ex As OleDbException
            MessageBox.Show(ex.Message)
            Return (False)
        End Try
    End Function

Image of Program

MinecrafDOB