开发者

Search all dates before a specific date in a database (VB.NET|OLE)

I have a database (MDB, Acce开发者_StackOverflowss) and I connect it to my program using an OLE object, now I have in the db a column filled with dates (ddmmyy),

I want to search and view (in Data grid view) all the fields that has a date before a Specific Date that I define .

the code of search that I used is :

 SQLstr = "SELECT * FROM tb WHERE anomber = '" & TextBox1.Text & "'"

What do I have to do?. Thanks.


use the parameters to pass the date to the query, it's more saver(no sql injection) and more perfect(it will convert the date format to the correct format)

SQLstr = "SELECT * FROM tb WHERE anomber < ?"
Command.Parameters.Add(New OleDbParameter("@anomber", TextBox1.Text))
Command.CommandText = SQLstr 

Edit: if the anomber field is the date field so the user can use < instead of =.

the OP question not clear about what he wants.

Edit2: after executing the command you should assign the results to the grid that you are using to display the data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜