I am connecting a VB Form Program to an access database. 3 of the 4 tables in the database are connected and working in their proper datagridviews but the last one is not connecting properly. the code for all connections is the same.
What I have tried:
so i traced the issue with msgbox outputs to when i am populating my variables.
the settings.DA.fill just above the commented out lines. if i comment out the fill line the program will run and give both loc messages but with it active the code gets stuck and wont proceed with, but instead ignores the rest of the code keeps the database open.
Imports System.Data.OleDb
Public Class Admin
Dim provider As String = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source =")
Dim dataFile As String = ("Filelocaty.mdb")
Dim connString As String = provider & dataFile
Dim myConnection As OleDbConnection = New OleDbConnection
Dim con As OleDbConnection = New OleDbConnection(connString)
Dim infoDA As OleDbDataAdapter
Dim infoDS As DataSet
Dim cmd1 As New OleDbCommand("SELECT * FROM Info", con)
Dim RoomDA As OleDbDataAdapter
Dim RoomDS As DataSet
Dim cmd2 As New OleDbCommand("SELECT * FROM Rooms", con)
Dim userDA As OleDbDataAdapter
Dim userDS As DataSet
Dim cmd3 As New OleDbCommand("SELECT * FROM Logins", con)
Dim settingDA As OleDbDataAdapter
Dim settingDS As DataSet
Dim cmd4 As New OleDbCommand("SELECT * FROM General", con)
Private Sub Admin_Load(sender As Object, e As EventArgs) Handles MyBase.Load
con.Open()
infoDA = New OleDbDataAdapter(cmd1)
Dim builder1 As OleDbCommandBuilder = New OleDbCommandBuilder(infoDA)
infoDS = New DataSet
Me.infoDA.Fill(infoDS, "Info")
InfoDG.DataSource = infoDS.Tables("Info").DefaultView
InfoDG.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
RoomDA = New OleDbDataAdapter(cmd2)
Dim builder2 As OleDbCommandBuilder = New OleDbCommandBuilder(RoomDA)
RoomDS = New DataSet
Me.RoomDA.Fill(RoomDS, "Rooms")
RoomDG.DataSource = RoomDS.Tables("Rooms").DefaultView
RoomDG.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
userDA = New OleDbDataAdapter(cmd3)
Dim builder3 As OleDbCommandBuilder = New OleDbCommandBuilder(userDA)
userDS = New DataSet
Me.userDA.Fill(userDS, "Logins")
UserDG.DataSource = userDS.Tables("Logins").DefaultView
UserDG.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
settingDA = New OleDbDataAdapter(cmd4)
Dim builder4 As OleDbCommandBuilder = New OleDbCommandBuilder(settingDA)
settingDS = New DataSet
MsgBox("Loc A")
settingDA.Fill(settingDS, "General")
'SettingsDG.DataSource = settingDS.Tables("General").DefaultView
'SettingsDG.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
MsgBox("Loc b")
con.Close()
End Sub
if anyone knows where i went wrong please let me know! from what i can tell the code is fine and i have checked my database thoroughly.