R
Royer12
Guest
Hello, I have a database that I connect as follows
Public Class Frm2
Dim cnn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= data.accdb;Persist Security Info=False")
Private Sub Frm2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim sql As String = "SELECT Alumn.Id_school,Esc.school FROM Esc,Alumn"
Cmb_scuel.DataSource = loadded(sql)
Cmb_scuel.DisplayMember = "school" 'table Esc name
Cmb_scuel.ValueMember = "Id_school" 'table Alumn id
Private Function loadded(sql As String) As DataTable
Dim dt As New DataTable
Using cmd As New OleDbCommand(sql, cnn)
cnn.Open()
Dim adapter As New OleDbDataAdapter(cmd)
adapter.Fill(dt)
cnn.Close()
End Using
Return dt
End Function
End Sub
End Class
it turns out that when compiling, the same data is displayed in the combobox but they are repeated constantly.
just to clarify, I have 4 data and these four are repeated 5 times
that is 4x5 = 20 datas.
Continue reading...
Public Class Frm2
Dim cnn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= data.accdb;Persist Security Info=False")
Private Sub Frm2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim sql As String = "SELECT Alumn.Id_school,Esc.school FROM Esc,Alumn"
Cmb_scuel.DataSource = loadded(sql)
Cmb_scuel.DisplayMember = "school" 'table Esc name
Cmb_scuel.ValueMember = "Id_school" 'table Alumn id
Private Function loadded(sql As String) As DataTable
Dim dt As New DataTable
Using cmd As New OleDbCommand(sql, cnn)
cnn.Open()
Dim adapter As New OleDbDataAdapter(cmd)
adapter.Fill(dt)
cnn.Close()
End Using
Return dt
End Function
End Sub
End Class
it turns out that when compiling, the same data is displayed in the combobox but they are repeated constantly.
just to clarify, I have 4 data and these four are repeated 5 times
that is 4x5 = 20 datas.
Continue reading...