Hey!
So i just started reading through some Database tuts, because i needed it for a project that i am making. I am using the HomeandLearn tutorial. So i have a database called "AdressBook" and then this code.
Public Class Form1
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
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:\Users\oliver\Downloads\AddressBook\AddressBook.mdb"
con.ConnectionString = dbProvider & dbSource
con.Open()
sql = "SELECT * FROM tblContacts"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "AddressBook")
con.Close()
TextBox1.Text = ds.Tables("AdressBook").Rows(0).Item(1)
TextBox2.Text = ds.Tables("AdressBook").Rows(0).Item(2)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
I get an error
Object reference not set to an instance of an object.
at
TextBox1.Text = ds.Tables("AdressBook").Rows(0).Item(1)
And i would probably get it at the next if it had the chance to get that far.
Any suggestions?
Thank you
Regards, Olivis.