title: Database Access in VB.NET
body: <p>I have accessed a database in VB.NET using the following code:  </p>
  
  <pre><code>Public Class Form1
      Private Sub btnLoad_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles btnLoad.Click
          Dim con As OleDb.OleDbConnection = 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 = AddressBook.mdb"
          con.ConnectionString = dbProvider &amp; dbSource
          con.Open()
          sql = "SELECT * FROM tblContacts"
          da = New OleDb.OleDbDataAdapter(sql, con)
          da.Fill(ds, "Address Book")
          MsgBox("Database Open")
          con.Close()
          MsgBox("Database Closed")
          txtFirstName.Text = ds.Tables("AddressBook").Rows(0).Item(1)
          txtSurname.Text = ds.Tables("AddressBook").Rows(0).Item(2)
      End Sub
  End Class  
  </code></pre>
  
  <p>However in line "txtFirstName.Text = ds.Tables("AddressBook").Rows(0).Item(1)", it gives me an exception saying that an instance of an object should be created. I am not understanding what exactly the problem is. How can I create an instance, and of WHAT should I create an instance?</p>