“如何使DataGridView仅输出我想要的数据? [英] "How to make the DataGridView output only the data that I want?
问题描述
使用Visual Studio 2010访问
我是用什数据库仅使用例如Birthdate =今天的日期而不是年份..
我正在制作这个bday提醒程序,只是一个简单的日常提醒谁将有一个生日。
< img src =http://i.imgur.com/ fVqPfse.jpgtitle =source:imgur.com/>
我已编码插入数据,现在我只想查看只使用月份和日期生日具有相同日期(不包括年份)的数据。
Db: access
im using Visual studio 2010
what syntax to use for making the datagridview output only the data that is in the database only using for example Birthdate = date today not the year..
im making this bday reminder program, just a simply day to day reminder who will be having a birthday.
<img src="http://i.imgur.com/fVqPfse.jpg" title="source: imgur.com" />
I already coded the insert data, now i just want to view the data that has birthday with the same date (not including the year) just by using the Month and Date.
推荐答案
我不确定我的语法是否正确我不想打开Access并查找,但想法是你在Access中使用DatePart函数。您可以用它来比较日期的各个部分。尝试类似:
I'm not sure I have the syntax correct as I don't want to open Access and find out, but the idea is that you use the DatePart function in Access. You can compare parts of dates with it. Try something like:
SELECT * FROM BIRTHDAY_TABLE
WHERE DatePart ("m", [BDAY_FIELD]) = DatePart("m",Date()) AND
DatePart("d",[BDAY_FIELD]) = DatePart("d",Date())
(可能有一个DatePart arg允许在一次比较中比较没有年份的月和日)
(There might be a DatePart arg that allows comparison for month and day without the year in a single comparison)
有点混淆这个部分.. = /
kinda confused on this part.. =/
If Not con.State = ConnectionState.Open Then
con.Open()
End If
Dim da As OleDb.OleDbDataAdapter
Dim Sql As String
Sql = "SELECT * FROM bene_records where b_date" ''<---This part....I dont know what to do next..
da = New OleDb.OleDbDataAdapter(Sql, con)
Dim dt As New DataTable
da.Fill(dt)
con.Close()
这篇关于“如何使DataGridView仅输出我想要的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!