แต่มันรันไม่ผ่านซักที ติดที่ Data type mismatch in criteria expression. ที่ชี้มาจาก dr = cm.ExecuteReader
อยากให้ผู้รู้ช่วยชี้แนะหน่อยครับ งานด่วนจริงๆครับ
Sub Load_DG1()
If Me.RadioButton1.Checked Then
Dim cn As New OleDbConnection(strConn)
cn.Open()
Dim sql As String
Dim cm As OleDbCommand
Dim dr As OleDbDataReader sql = "select o.or_id,o.or_date,o.or_datend,c.c_name from orders o inner join customer c on o.c_id = c.c_id "
sql &= "where o.or_return='0' AND o.or_datend = '" & Me.DTP1.Value.Date() & "'" If Me.txtSearch.Text.Trim <> "" Then
Select Case Me.cmbCondition.SelectedIndex 'AND o.or_datend = '" & Me.DTP1.Value.ToShortDateString & "'"
Case 0
sql &= " and c.c_name like '" & Me.txtSearch.Text.Trim & "%'"
End Select
End If
'MsgBox(Me.DTP1.Value.Date())
sql &= " order by o.or_id "
cm = New OleDbCommand(sql, cn)
dr = cm.ExecuteReader
Me.DG1.Rows.Clear()
While dr.Read
Dim item(3) As String
item(0) = dr.GetInt32(0).ToString
item(1) = dr.GetDateTime(1).ToString("dd/MM/yyyy")
item(2) = dr.GetDateTime(2).ToString("dd/MM/yyyy")
item(3) = dr.Item(3).ToString
Me.DG1.Rows.Add(item)
End While
dr.Close()
cn.Close()