Socarsky
Well-known member
The query string is right and tested on Access successfully but there is something wrong that caused not to get result in DataGridView? Can You figure out what's the matter? The program is simple one, combobox control gets all employees name when it runs and when you pick up a name then check in and out must be show off in DataGridView.
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged num = CShort(num + 1) Dim cmbStr As String cmbStr = ComboBox1.GetItemText(ComboBox1.SelectedItem) MessageBox.Show(cmbStr.ToString) If num <> 0 Then Try If (CONN.State = ConnectionState.Closed) Then CONN.Open() End If Dim da As New OleDb.OleDbDataAdapter("SELECT USERINFO.Name, CHECKINOUT.CHECKTIME FROM USERINFO LEFT JOIN CHECKINOUT ON USERINFO.USERID = CHECKINOUT.USERID WHERE USERINFO.Name Like '" & cmbStr & "*';", CONN) Dim ds As New DataSet Dim cmd As New OleDb.OleDbCommandBuilder(da) ds.Clear() DataGridView1.DataSource = ds.Tables.Add("att2000") da.Fill(ds, "att2000") Catch ex As Exception MsgBox(ex.ToString) End Try End If End Sub
Last edited: