I want to fill the first ComboBox with data from another table, fill the second ComboBox with data from another table, and fill the DataGridView with the table that have relationships with both of the other table.
The problem I was talking about.
The relationship that I create
When I tried to do just that, the first ComboBox shows gibberish “System.Data.DataRowView” while the other ComboBox shows an blank and a correct data. The DataGridView on the other hand show rows with a single data in it.
Imports System.Data.OleDb
Public Class RegisterMarkLabTask
Dim conn As New OleDbConnection
Dim cmd As OleDbCommand
Dim dt As New DataTable
Dim da As New OleDbDataAdapter(cmd)
Private Sub RegisterMarkLabTask_Load(sender As Object, e As EventArgs) Handles MyBase.Load
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:UsersASUSDocumentsProject2.accdb"
viewer()
End Sub
Private Sub viewer()
dt.Clear()
DataGridView1.DataSource = dt
DataGridView1.DataSource = Nothing
conn.Open()
cmd = conn.CreateCommand()
cmd.CommandType() = CommandType.Text
da = New OleDbDataAdapter("select * from LabTaskMark", conn)
da.Fill(dt)
DataGridView1.DataSource = dt
da = New OleDbDataAdapter("select StudentMatricNo from Student", conn)
da.Fill(dt)
cbLabTaskID.DisplayMember = "StudentMatricNo"
cbLabTaskID.DataSource = dt
da = New OleDbDataAdapter("select LabTaskID from LabTask", conn)
da.Fill(dt)
cbLabTaskID.DisplayMember = "LabTaskID"
cbStudentMatricNo.DataSource = dt
conn.Close()
End Sub
End Class
Oofie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.