i trying to put this in the combobox why did not come out

Private Sub Lecturer_Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim conn As New System.Data.OleDb.OleDbConnection()
    conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb"


    If conn.State = ConnectionState.Open Then conn.Close()
    conn.Open()
    Dim sql As String = "Select [StaffNo] From tbl_lecturer " And "Select [ProjectNo] From tbl_assignment " And "Select [AdminNo] From tbl_info "
    Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, conn)
    sqlCom.Connection = conn
    Dim sqlReader As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader()

    If sqlReader.HasRows Then
        While (sqlReader.Read)

            ComboBoxstaff.Items.Add(sqlReader.Item("StaffNo").ToString)
            ComboBoxstaff.Items.Add(sqlReader.Item("ProjectNo").ToString)
            ComboBoxstaff.Items.Add(sqlReader.Item("AdminNo").ToString)
        End While
    End If

End Sub

End Class

Attachments LTS.jpg 64 KB

Dim sql As String = "Select [StaffNo] From tbl_lecturer " And "Select [ProjectNo] From tbl_assignment " And "Select [AdminNo] From tbl_info "

This is not a valid SQL Statement.
It should be

 Dim sql As String = "Select A.StaffNo, B.ProjectNo, C.AdminNo From tbl_lecturer A, tbl_assignment B, tbl_info C"

And the part of your codes

If sqlReader.HasRows Then
While (sqlReader.Read)
ComboBoxstaff.Items.Add(sqlReader.Item("StaffNo").ToString)
ComboBoxstaff.Items.Add(sqlReader.Item("ProjectNo").ToString)
ComboBoxstaff.Items.Add(sqlReader.Item("AdminNo").ToString)
End While
End If

should be

If sqlReader.HasRows Then
        While (sqlReader.Read)
            ComboBoxstaff.Items.Add(sqlReader.Item("StaffNo").ToString)
            ComboBoxprojno.Items.Add(sqlReader.Item("ProjectNo").ToString)
            ComboBoxadmnno.Items.Add(sqlReader.Item("AdminNo").ToString)
        End While
    End If

Edited 2 Years Ago by Shark_1

after i choose the 3 combobox how to get the tbl_info of the user name and tbl_lecturer time in and out in the textbox and the listbox time in and out..!

Attachments !!.jpg 75.32 KB
This article has been dead for over six months. Start a new discussion instead.