没有给出一个或多个必需参数的值。 [英] No value given for one or more required parameters.
问题描述
大家好,
我遇到日期过滤问题...
我收到错误消息:
OleDbException未处理
没有给出一个或多个必需参数的值。
以下是我的代码:
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:
'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()
希望有人可以提供帮助我在这里
提前感谢
嗨大家好,
感谢您的回复。但是,这不是问题。在上面的代码中,我忘记删除我在SQL中尝试样本时使用的where isDate。这是原始的SQL idSQL = SELECT * FROM Newtransaction
顺便说一下,这些代码插入到txtSearch文本框的TextChange中。这是因为,我想按发布日期过滤掉记录。希望有人能给我一个答案。谢谢!
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!
推荐答案
要从MS Access数据库中获取数据,请使用以下命令:/ b $ b
To fetch data from MS Access database, use sql command like this:
SELECT *
FROM Newtransaction
WHERE [DateField] = #2012/06/01#
SELECT *
FROM Newtransaction
WHERE [DateField] BETWEEN #2012/05/01# AND #2012/05/31#
记住!日期格式取决于您的系统区域(日期)设置!
更多信息:
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 [ ^ ]
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[^]
Hello,
请更正行 -
Hello,
please correct the line-
idSQL = "SELECT * FROM Newtransaction where isDate "
to
idSQL = "SELECT * FROM Newtransaction where isDate ='DATE'"
或者使用以下内容 -
Or use the following-
idSQL = "SELECT * FROM Newtransaction"
这篇关于没有给出一个或多个必需参数的值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!