Error using date picker control

Solved/Closed
mikeoe2003 Posts 25 Registration date Thursday November 1, 2012 Status Member Last seen March 27, 2014 - Jan 26, 2013 at 04:26 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Jan 26, 2013 at 10:44 AM
Hello,


Hi I am trying to use the value entered in a datepicker control as a parameter in a query but I kept getting error please find below different constructions I used and associated errors.
1) da = New OleDbDataAdapter("select * from student_info Where Bday =" & DateTimePicker_Select.Value & "", con)

ERROR: Synthax error (missing operator) in querry epression 'Bday=10/1401972 9:48:00 AM'.
2) da = New OleDbDataAdapter("select * from student_info Where Bday =" & DateTimePicker_Select.Text & "", con)

ERROR: The above construct returns empty rows just colum names and empty rows.



====================================================
Private Sub birthday_saerch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles birthday_saerch.Click
Dim con As New OleDbConnection
con.ConnectionString = _
"provider=Microsoft.JET.OLEDB.4.0; " & _
"data source = '" & Application.StartupPath & "\school_record.mdb'"
Dim ds As New DataSet
Dim dt As New DataTable
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter
'da = New OleDbDataAdapter("select * from student_info Where matric_number =" & txt_serach.Text & "", con)
da = New OleDbDataAdapter("select * from student_info Where Bday =" & DateTimePicker_Select.Value & "", con)
'da = New OleDbDataAdapter("select * from student_info Where Bday =" & DateTimePicker_Select.Text & "", con)
da.Fill(dt)
dv.DataSource = dt.DefaultView
con.Close()
End Sub

Related:

1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Jan 26, 2013 at 10:44 AM
try this

da = New OleDbDataAdapter("select * from student_info Where Format(Bday, ""yyyymmdd"") = " & format(DateTimePicker_Select.Text, "yyyymmdd") & "", con)
0