2014-10-31 90 views
0

這是我不知道語法的部分 我希望我的表單通過使用b_date自動加載數據庫 中的數據,但只顯示記錄(如果月份中有匹配的話)而不是使用一年日期 ,該計劃是像一個生日提醒WHERE的語法正確

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
     'TODO: This line of code loads data into the 'Bene_dbDataSet.bene_records' table. You can move, or remove it, as needed. 
     Me.Bene_recordsTableAdapter.Fill(Me.Bene_dbDataSet.bene_records) 

     con = New OleDb.OleDbConnection 
     dbProvider = "Provider=Microsoft.Jet.OLEDB.4.0;" 
     dbSource = "Data Source = C:\Users\RedemptorisMater\Desktop\S\K\WindowsApplication1\WindowsApplication1\bene_db.mdb" 

     con.ConnectionString = dbProvider & dbSource 

     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" 
     da = New OleDb.OleDbDataAdapter(Sql, con) 

     Dim dt As New DataTable 
     da.Fill(dt) 

     con.Close() 

     My.Computer.Audio.Play("C:\Users\R\Desktop\S\Kenton\WindowsApplication1\WindowsApplication1\bday1.wav", 
     AudioPlayMode.Background) 

    End Sub 

回答

0

你不提,你會指定日和月,因此要獲得一個特定的d/M:

SELECT bene_records.*, Day([b_date]) AS MyDay, Month([b_date]) AS MyMonth 
FROM bene_records 
WHERE (((Day([b_date]))=1) AND ((Month([b_date]))=11)); 

你可以代表用你自己的標準來記錄硬編碼的日期/月份。