THE WAY FORWARD IN THE ICT WORLD
   
 
  DATABASE/VB.NET CODES
HELLO GUYS .IS VB.NET KIND OF PROVING DIFFICULT TO YAH.TRY OUT THIS IN YAH CODES AND JUST COPY AND PASTE THIS CODE TO YAH FORMS BUT REMEMBER TO MAKE ADJUST MENTS WHERE NECESSARY THAT IS ACCORDING TO YAH FORM DESIGN.IF ALL DOES NOT WORK CONTACT ME.IF IT ALL FAILS TO WORK OUT JUST SEE ME N AM GONNA CODE IT FOR YAH.IF YAH STILL NEED SOME COURSE WORK DONE FOR YAH JUST HOLLA ME AND COME WHILE YAH POCKET IS LOADED.ITS NOT EASY AS YOU MAY THINK BUT JUST TRY OUT THIS SIMPLIFIED CODES

 

Imports System.Data

Public Class Form1

 Dim cb As New OleDb.OleDbCommandBuilder(da)

    Dim inc As Integer

    Dim MaxRows As Integer

    Dim sql As String

    Dim con As New OleDb.OleDbConnection

    Dim ds As New DataSet

    Dim da As OleDb.OleDbDataAdapter

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

   con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:Database.mdb"

        con.Open()

        sql = "SELECT * FROM Tablevb"

        da = New OleDb.OleDbDataAdapter(sql, con)

  da.Fill(ds, "AddressBook")

        con.Close()

   MaxRows = ds.Tables("AddressBook").Rows.Count

        inc = -1

 End Sub

 Private Sub NavigateRecords()

  txtFirstName.Text = ds.Tables("AddressBook").Rows(inc).Item(1)

        txtSurname.Text = ds.Tables("AddressBook").Rows(inc).Item(2)

 End Sub

 Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click

        If inc <> MaxRows - 1 Then

            inc = inc + 1

            NavigateRecords()

        Else

            MsgBox("No More Rows")

        End If

End Sub

 Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click

        If inc > 0 Then

            inc = inc - 1

            NavigateRecords()

        ElseIf inc = -1 Then

            MsgBox("No Records Yet")

        ElseIf inc = 0 Then

            MsgBox("First Record")

        End If

  End Sub

 

    Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click

        If inc <> 0 Then

            inc = 0

            NavigateRecords()

        End If
End Sub

  Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click

        If inc <> MaxRows - 1 Then

            inc = MaxRows - 1

            NavigateRecords()

        End If

End Sub

  Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click

        Dim cb As New OleDb.OleDbCommandBuilder(da)

 ds.Tables("AddressBook").Rows(inc).Item(1) = txtFirstName.Text

        ds.Tables("AddressBook").Rows(inc).Item(2) = txtSurname.Text

   da.Update(ds, "AddressBook")

  MsgBox("Data updated")

 End Sub

  Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click

        btnSave.Enabled = False

        btnAdd.Enabled = True

        btnUpdate.Enabled = True

        btnDelete.Enabled = True

  inc = 0

        NavigateRecords()

End Sub

  Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

        btnSave.Enabled = True

        btnAdd.Enabled = False

        btnUpdate.Enabled = False

        btnDelete.Enabled = False
txtFirstName.Clear()

   txtSurname.Clear()

End Sub

 Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

        If inc <> -1 Then

   Dim cb As New OleDb.OleDbCommandBuilder(da)

            Dim dsNewRow As DataRow

   dsNewRow = ds.Tables("AddressBook").NewRow()

   dsNewRow.Item("FirstName") = txtFirstName.Text

            dsNewRow.Item("Surname") = txtSurname.Text

   ds.Tables("AddressBook").Rows.Add(dsNewRow)

 da.Update(ds, "AddressBook")

 MsgBox("New Record added to the Database")

  btnSave.Enabled = False

            btnAdd.Enabled = True

            btnUpdate.Enabled = True

            btnDelete.Enabled = True

  End If

  End Sub

  Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click

        If MessageBox.Show("Do you really want to Delete this Record?", "DELETE", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.No Then

MsgBox("Operation Cancelled")

            Exit Sub

 ds.Tables("AddressBook").Rows(inc).Delete()

            MaxRows = MaxRows - 1
  inc = 0

            NavigateRecords()

            da.Update(ds, "AddressBook")

End If

End Sub

End Class

 

 

 

RASJOHILL'S WEBSITE TIME KEEPER
 
CHATROOM WINDOW
 

Free chat widget @ ShoutMix
RASJOHILL'S OTHER WEBSITES
 
1) http://www.johill.synthasite.com

2) http://www.reggaevideo.weebly.com

3) http://www.zazzle.com/rasjohill

4) http://www.rasjohill.blogspot.com

5) http://www.johil.blogspot.com

6) http://www.myspace.com/johill
RASJOHILL'S WEBCOUNTER
 
GET COUNTED IN RASJOHILLS WEBSITE
RASJOHILL'S UPDATES COLUMNS
 
sunday updates

THIS IS A NOTICE AM MAKING TO ALL THOSE WHO LOVED THE RASTAFARIAN TEACHINGS THAT WERE CURRENTLY ON THIS SITE.PLEASE NOTE THAT THEY HAVE BEEN TRANSFERED TO http://www.johill.synthasite.com and more reggae videos on
http://reggaevideo.weebly.com.Am sorry for any inconvinieces caused.


Jarget just got a job in New Jersey through this site.see his comment on the jobs column


NOTE

1.This site is still under construction and any content in this website is subjected to any change without users notice.however i personally apologize for any inconveniences that may be caused in the near future

2.It was difficut to try and locate the relevant link up sites and this is all the best that i could find in the net as pertains my pages.however you may notice that some sites arent relevant to the topics posted or fields highlighted but i also hope you know the way google search engines bring out results so bear with me.nevertheless you may assume that a certain link aint related to my topics but actually they are just try them and you will see the sense am trying to drive at here.

3.Keep coming since more data will be added almost dailly to keep updated helpful information to all of you

THANKS ALOT FOR BEING A VISITOR OF THIS PAGE

 
Ever since this website was created(June 20 Friday 2008), there have been 13 visitors (18 hits) today
THE END OF AN ERA This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free