Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
1.70/5 (3 votes)
See more:
Hi Guys,

I'm having problems with date filtering...

I got an error Message:
OleDbException was unhandled
No value given for one or more required parameters.

Below are my codes:

VB
'declare the needed variables
          Dim idCon As New OleDbConnection
          Dim idSQL As String
          Dim idSet As New DataSet

          'start the connection
          idCon.ConnectionString = "PROVIDER = Microsoft.Jet.OleDb.4.0; data source = Library2.mdb; Jet OLEDB:Database Password = 3Musketeers"
          idSQL = "SELECT * FROM Newtransaction"
          'declare and assign a value to a dataadapter
          Dim idAdapt As New OleDbDataAdapter(idSQL, idCon)
          'open the connection

          Dim mytable As DataTable = New DataTable()

          idCon.Open()
          'fill data to datable
          idAdapt.Fill(idSet, "suckz")

          dGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
          'setting columnheadername
          idSet.Tables("suckz").Columns(0).ColumnName = "T CODE"
          idSet.Tables("suckz").Columns(1).ColumnName = "BOOK CODE"
          idSet.Tables("suckz").Columns(2).ColumnName = "MEMBER CODE"
          idSet.Tables("suckz").Columns(3).ColumnName = "ISSUED_DATE"
          idSet.Tables("suckz").Columns(4).ColumnName = "RETURNED DATE"
          idSet.Tables("suckz").Columns(5).ColumnName = "COMMENTS"
          idSet.Tables("suckz").Columns(6).ColumnName = "PENALTY"

          BindingSource1.DataSource = idSet.Tables("suckz")

          BindingSource1.Filter = String.Format("ISSUED_DATE LIKE '{0}%'", txtSearch.Text)

          dGrid.DataSource = BindingSource1
          dGrid.Update()
          dGrid.Refresh()
          idCon.Close()



hope someone could help me here


thanks in advance

Hi Guys,

Thank you for your response guys. However, it's not really the problem here. In the above codes, I forgot to delete "where isDate" in my SQL which I used when I tried a sample one. Here is the original SQL idSQL = "SELECT * FROM Newtransaction" By the way, those codes are inserted in TextChange of txtSearch textbox. This is because, I want to filter out records by issued date. Hope someone could give me an answer. thanks!
Posted
Updated 7-Jul-20 23:18pm
v4
Comments
tanweer 31-May-12 4:12am    
please correct this
idSQL = "SELECT * FROM Newtransaction where isDate "
to
idSQL = "SELECT * FROM Newtransaction where isDate ='SOME DATE'"
Ed Nutting 31-May-12 4:20am    
Good response but I can't upvote :( My virtual 5+ then :)
Ed
moodyCoder 31-May-12 4:39am    
Thank you for your response guys. However, it's not really the problem here. In the above codes, I forgot to delete "where isDate" in my SQL which I used when I tried a sample one. Here is the original SQL

idSQL = "SELECT * FROM Newtransaction"

By the way, those codes are inserted in TextChange of txtSearch textbox. This is because, I want to filter out records by issued date.

Hope someone could give me an answer. thanks!

To fetch data from MS Access database, use sql command like this:
SQL
SELECT *
FROM Newtransaction
WHERE [DateField] = #2012/06/01#


SQL
SELECT *
FROM Newtransaction
WHERE [DateField] BETWEEN #2012/05/01# AND  #2012/05/31#


Remember! Date format depends of your system regional (date) settings!

More at:
http://www.techrepublic.com/article/10-tips-for-working-with-dates-in-microsoft-access/6135056[^]
http://stackoverflow.com/questions/10232187/query-to-retrieve-data-of-specific-date-in-msaccess[^]
 
Share this answer
 
v2
Comments
VJ Reddy 5-Jun-12 19:56pm    
Good answer.5!
Maciej Los 6-Jun-12 9:03am    
Thank you, VJ ;)
Hello,
please correct the line-
VB
idSQL = "SELECT * FROM Newtransaction where isDate "
to
VB
idSQL = "SELECT * FROM Newtransaction where isDate ='DATE'"

Or use the following-
VB
idSQL = "SELECT * FROM Newtransaction"
 
Share this answer
 
v2
Comments
moodyCoder 31-May-12 4:42am    
Thank you for your response guys. However, it's not really the problem here. In the above codes, I forgot to delete "where isDate" in my SQL which I used when I tried a sample one. Here is the original SQL idSQL = "SELECT * FROM Newtransaction" By the way, those codes are inserted in TextChange of txtSearch textbox. This is because, I want to filter out records by issued date. Hope someone could give me an answer. thanks!
Sinisa Hajnal 17-Jun-16 2:41am    
This is not the solution. Javed, you should delete this, especially since you wrote it five hours after the comments saying the same.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900