I can't understand why my Access database won't load into a DataGridView for me. I have no errors within my code so I'm unsure as to what is going on. The only error I'm getting is the configuration element is not declared.
Imports System.Data.OleDb
Public Class Form1
Dim conn As New OleDbConnection
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim objConn As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source = Students.accdb"
conn.Open()
dataGridShow()
End Sub
Private Sub dataGridShow()
Dim objDS As New DataSet
Dim objDT As New DataTable
objDS.Tables.Add(objDT)
Dim objDA As New OleDb.OleDbDataAdapter
objDA = New OleDbDataAdapter("SELECT * FROM Students", conn)
objDA.Fill(objDT)
DataGridView1.DataSource = objDT.DefaultView
conn.Close()
End Sub
End Class
My app config looks like this. My database is located in bin/Debug
<?xml version="1.0" encoding="utf-8"?
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<connectionStrings>
</connectionStrings>
</configuration>