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

Recommended Answers

All 3 Replies

Line 8 is not a valid query.

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

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..!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.