I Want To Search Date From .mdb Database file, Table Name is Purchase, and The Field is Purchase Date, its Type is DateTime and Formate is ShortDate in MS Access Database File,

I Conceted it to Vb.net Form, and Tryed to Search Date, but it Returns Error. the Code to Connect and Search Date Record is as Follows

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
              
        PurchaseConn.ConnectionString = "Provider=Microsoft.jet.oledb.4.0; Data Source=" & Pth & "\DisplayCenterData.mdb; User Id=admin; Password=;"

'pth is Variable for Project Folder's Path

        PurchaseSql = "Select * from PUrchase where PurchaseDate =" & DatePurchaseFrm.Value & " order By PUrchaseID"

'DatePurchaseFrm is DateTime Picker Tool of vb.net, yes i also used to try its .text Property insted of .value but it  Returns 0 result


        PurchaseDa = New OleDbDataAdapter(PurchaseSql, PurchaseConn)

        PurchaseDs = New DataSet
        PurchaseDa.Fill(PurchaseDs, "DisplayCenterData")
        PurchaseDt = PurchaseDs.Tables("DisplayCenterData")

        PurchaseCmb = New OleDbCommandBuilder(PurchaseDa)
       
        PurchaseDa.InsertCommand = PurchaseCmb.GetInsertCommand
        PurchaseDa.UpdateCommand = PurchaseCmb.GetUpdateCommand

        DataGridPurchase.DataSource = PurchaseDt

 txtPurchaseID.DataBindings.Clear()
        txtCompanyID.DataBindings.Clear()
        txtBookID.DataBindings.Clear()
        txtPurchaseDate.DataBindings.Clear()

txtPurchaseID.DataBindings.Add("text", PurchaseDt, "purchaseID")
        txtCompanyID.DataBindings.Add("text", PurchaseDt, "companyID")
        txtBookID.DataBindings.Add("text", PurchaseDt, "BookID")
        txtPurchaseDate.DataBindings.Add("text", PurchaseDt, "PUrchaseDate")       
        
            End Sub

When I Tried To Run and Search The Date, it Returns following Error


<Syntax error (missing operator) in query expression 'PurchaseDate =>10/10/2010 12:53:17 AM'.>.

Point to note here is that i have not included any Time into PurchaseDate Field, nor in .mdb file and nither in vb.net form at adding Record time, I think Date Search function is not working just Because of Time included in it.

plz help to Solve or give any other IDea to search DAte from Table, yes i m planning to SEarch Date with Two Conditions, like
"Select * From Purchase Where PurchaseDate>=" & DtTmPicker1.value & " and PurchaseDate=<" & DtTmPicker2.value

Thanks in Advance

Correction:

PurchaseSql = "Select * from PUrchase where PurchaseDate ='" & DatePurchaseFrm.Value & "' order By PUrchaseID"

Advice:

Try to use parametrized query.

PurchaseSql = "Select * from PUrchase where PurchaseDate =@purdate  order By PUrchaseID"

Dear its not Working, i m sending u a short project zip file for this,
yes i m from Pakistan that’s why i set date format as dd/mm/yyyy, yes i also change it in windows system date format from <Control panel Reagional and language options/Date> so that user can enter data in this format in ms Access Database file,
i also changed Date format to short in msAccess file as well as set DateTimepickers' (DatePurchaseFrm and DatePurchaseto)'s format properties to Short and dd/mm/yyyy

I used following sql statements but not working

PurchaseSql = "Select * from PUrchase where PurchaseDate => '" & DatePurchaseFrm.Value '.ToString("dd-MM-yyyy") & "' order By PUrchaseID"


        PurchaseSql = "Select * from PUrchase where PurchaseDate =@05/04/2010  order By PUrchaseID"


        PurchaseSql = "SELECT * FROM purchase WHERE PUrchaseDate between '" & Format(Me.DatePurchaseFrm.Value, "dd/dd/yyyy") & "' AND '" & Format(Me.DatePurchaseTo.Value, "dd/MM/yyyy") & "'"


        PurchaseSql = "Select * from PUrchase where PurchaseDate ='" & DatePurchaseFrm.Value & "' order By PUrchaseID"

i used ur above given statement but its not working, further more i m sending projects zip file, plz help to solve

Regards

i would suggest you change the format of the field in MS Access from date/time to short date cos sometimes MS Access can be hell. just use the "Text" format of access, this would accept any data format.
if this does not work, then send me a message so i can send a sample project

This article has been dead for over six months. Start a new discussion instead.