Thursday, 20 January 2011

looks simpler then it really is!

I've now been "working" for my uncle for 10 days, and untill today, I thought programming was a bit easy, however now I started working on some of the harder stuff, like databases, and I tell you, I never imagined I had to write this much code this early into my "career".

Went from doing something as simple as:

Dim Answer as Integer

Answer = 5 + 5

Textbox1.Text = Answer

to writing:

 Dim con As New OleDb.OleDbConnection
        Dim dbProvider As String
        Dim dbSource As String
        Dim ds As New DataSet
        Dim da As OleDb.OleDbDataAdapter
        Dim Sql As String

        dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
        dbSource = "Data Source = C:\PATH"

        con.ConnectionString = dbProvider & dbSource

        con.Open()


        Sql = "SELECT * FROM tblContacts"
        da = New OleDb.OleDbDataAdapter(Sql, con)
        da.Fill(ds, "AddressBook")


        MsgBox("Database is now open")

        con.Close()

        MsgBox("Database is now Closed")

        txtFirstName.Text = ds.Tables("AddressBook").Rows(0).Item(1)
        txtSurname.Text = ds.Tables("AddressBook").Rows(0).Item(2)

But I still quite enjoy this guide!

-Rasmus Iversen

No comments:

Post a Comment