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