Hiyo,
I am having a lot of problems getting this datagridview to fill up properly, i would like to have some input on what i am doing wrong it is driving me bananas !!
So what i am trying to do is fill up 5 DataGridView (one on each tabs, one for each tables in the database) using DataTables that retrieve tables using a SQL query on my Access Database (.accdb) then i populate multiple combo boxes using a Dataset with the fields from the database which i then can use to filter the output to the Datagrid. I would also like to be able to edit the tables using this DataGridView with something like:
But for now my DataGridView doesnt fill up >_>
![]()
All the combo boxes tho populate perfectly. Here is my code i have so far:
I am having a lot of problems getting this datagridview to fill up properly, i would like to have some input on what i am doing wrong it is driving me bananas !!
So what i am trying to do is fill up 5 DataGridView (one on each tabs, one for each tables in the database) using DataTables that retrieve tables using a SQL query on my Access Database (.accdb) then i populate multiple combo boxes using a Dataset with the fields from the database which i then can use to filter the output to the Datagrid. I would also like to be able to edit the tables using this DataGridView with something like:
Code:
Private Sub cmdModBillets_Click(sender As Object, e As EventArgs) Handles cmdModBillets.Click
adp.Update(Billets)
End Sub

All the combo boxes tho populate perfectly. Here is my code i have so far:
Code:
Imports System.Data.OleDb
Public Class frmGrid
Dim Conn As New OleDbConnection
Dim cmdSQL As New OleDbCommand
Dim adpBillets As New OleDbDataAdapter
Dim dsBillets As New DataSet
Dim dtBillets As New DataTable
Dim adpTech As New OleDbDataAdapter
Dim dsTech As New DataSet
Dim dtTech As New DataTable
Dim adpSol As New OleDbDataAdapter
Dim dsSol As New DataSet
Dim dtSol As New DataTable
Dim adpEmp As New OleDbDataAdapter
Dim dsEmp As New DataSet
Dim dtEmp As New DataTable
Dim adpEquip As New OleDbDataAdapter
Dim dsEquip As New DataSet
Dim dtEquip As New DataTable
Private Sub frmGrid_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source = H://Database11.accdb;"
Conn.Open()
'Tab Billet ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cmdSQL.CommandText = "Select ID, TechnicienID, ClientID, Active, Solution FROM Billets"
cmdSQL.Connection = Conn
adpBillets.SelectCommand = cmdSQL
adpBillets.Fill(dsBillets)
adpBillets.Fill(dtBillets)
dgBillets.DataSource = dtBillets
cBID.Items.Clear()
cBT.Items.Clear()
cBC.Items.Clear()
cBA.Items.Clear()
cBS.Items.Clear()
For Each a In dsBillets.Tables(0).Rows
If Not cBID.Items.Contains(a(0)) Then
cBID.Items.Add(a(0))
End If
If Not cBT.Items.Contains(a(1)) Then
cBT.Items.Add(a(1))
End If
If Not cBC.Items.Contains(a(2)) Then
cBC.Items.Add(a(2))
End If
If Not cBA.Items.Contains(a(3)) Then
cBA.Items.Add(a(3))
End If
If Not cBS.Items.Contains(a(4)) Then
cBS.Items.Add(a(4))
End If
Next
cmdSQL.CommandText = ""
dsBillets.Clear()
dtBillets.Clear()
'Tab Tech ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cmdSQL.CommandText = "Select ID, Nom, Niveau, Specialite FROM Techniciens"
cmdSQL.Connection = Conn
adpTech.SelectCommand = cmdSQL
adpTech.Fill(dsTech)
adpTech.Fill(dtTech)
dgTech.DataSource = dtTech
cTID.Items.Clear()
cTN.Items.Clear()
cTNI.Items.Clear()
cTF.Items.Clear()
For Each a In dsTech.Tables(0).Rows
If Not cTID.Items.Contains(a(0)) Then
cTID.Items.Add(a(0))
End If
If Not cTN.Items.Contains(a(1)) Then
cTN.Items.Add(a(1))
End If
If Not cTNI.Items.Contains(a(2)) Then
cTNI.Items.Add(a(2))
End If
If Not cTF.Items.Contains(a(3)) Then
cTF.Items.Add(a(3))
End If
Next
cmdSQL.CommandText = ""
dsTech.Clear()
dtTech.Clear()
'Tab Solution ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cmdSQL.CommandText = "Select ID, Keywords, Type, Description FROM Solution"
cmdSQL.Connection = Conn
adpSol.SelectCommand = cmdSQL
adpSol.Fill(dsSol)
adpSol.Fill(dtSol)
dgSolutions.DataSource = dtSol
cSID.Items.Clear()
cSK.Items.Clear()
cST.Items.Clear()
For Each a In dsSol.Tables(0).Rows
If Not cSID.Items.Contains(a(0)) Then
cSID.Items.Add(a(0))
End If
If Not cSK.Items.Contains(a(1)) Then
cSK.Items.Add(a(1))
End If
If Not cST.Items.Contains(a(2)) Then
cST.Items.Add(a(2))
End If
Next
cmdSQL.CommandText = ""
dsSol.Clear()
dtSol.Clear()
'Tab Employe ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cmdSQL.CommandText = "Select ID, Nom, Prenom, Telephone, Bureau, Departement, Poste FROM Employe"
cmdSQL.Connection = Conn
adpEmp.SelectCommand = cmdSQL
adpEmp.Fill(dsEmp)
adpEmp.Fill(dtEmp)
dgEmploye.DataSource = dtEmp
cEID.Items.Clear()
cEN.Items.Clear()
cEP.Items.Clear()
cET.Items.Clear()
cEB.Items.Clear()
cED.Items.Clear()
cEPO.Items.Clear()
For Each a In dsEmp.Tables(0).Rows
If Not cEID.Items.Contains(a(0)) Then
cEID.Items.Add(a(0))
End If
If Not cEN.Items.Contains(a(1)) Then
cEN.Items.Add(a(1))
End If
If Not cEP.Items.Contains(a(2)) Then
cEP.Items.Add(a(2))
End If
If Not cET.Items.Contains(a(3)) Then
cET.Items.Add(a(3))
End If
If Not cEB.Items.Contains(a(4)) Then
cEB.Items.Add(a(4))
End If
If Not cED.Items.Contains(a(5)) Then
cED.Items.Add(a(5))
End If
If Not cEPO.Items.Contains(a(6)) Then
cEPO.Items.Add(a(6))
End If
Next
cmdSQL.CommandText = ""
dsEmp.Clear()
dtEmp.Clear()
'Tab Equipment~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cmdSQL.CommandText = "Select SerialNumber, Type, Description, Warranty, DateOfPurchase FROM Equipement"
cmdSQL.Connection = Conn
adpEquip.SelectCommand = cmdSQL
adpEquip.Fill(dsEquip)
adpEquip.Fill(dtEquip)
dgEquip.DataSource = dtEquip
cEQS.Items.Clear()
cEQT.Items.Clear()
cEQW.Items.Clear()
cEQD.Items.Clear()
For Each a In dsEquip.Tables(0).Rows
If Not cEQS.Items.Contains(a(0)) Then
cEQS.Items.Add(a(0))
End If
If Not cEQT.Items.Contains(a(1)) Then
cEQT.Items.Add(a(1))
End If
If Not cEQW.Items.Contains(a(2)) Then
cEQW.Items.Add(a(2))
End If
If Not cEQD.Items.Contains(a(3)) Then
cEQD.Items.Add(a(3))
End If
Next
cmdSQL.CommandText = ""
dsEquip.Clear()
dtEquip.Clear()
Conn.Close()
End Sub
End Class