VB代码,用于为数据库中列出的任务创建弹出提醒 [英] VB code to create pop-up reminders for tasks listed in a database that are due
问题描述
你可以帮我把VB代码放在一起,当用户登录到Access数据库时,当任务日期等于当前日期或者过期时,它会使弹出提醒出现吗?
Could you help me to put together the VB code that would enable a pop-up reminder to appear when a user logs on to an Access database, when the task date equates to the current date or is over-due?
推荐答案
你提到过你正在使用VB。
you had mentioned that you are using VB.
所以这里我假设你正在谈论VB.Net而不是关于VBA。
so here I assume that you are talking about VB.Net and not about VBA.
下面是一个例子。
我创建了一个名为"task"的表1在Access中并将数据插入其中。
I create 1 table named "task" in Access and insert data in to it.
然后我用VB创建Windows应用程序。
then I create Windows Application using VB.
下面是代码。
Imports System.Data.OleDb
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ReadData("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Backup 22-11-2016\Database2.mdb", "select * from task")
End Sub
Public Sub ReadData(ByVal connectionString As String,
ByVal queryString As String)
Using connection As New OleDbConnection(connectionString)
Dim command As New OleDbCommand(queryString, connection)
Dim dt, dt1 As Date
dt = Format(DateTime.Now, "MM/dd/yyyy").ToString
connection.Open()
Dim reader As OleDbDataReader = command.ExecuteReader()
While reader.Read()
dt1 = reader(2).ToString()
Console.WriteLine(reader(0).ToString())
If (dt1 >= dt) Then
Me.TextBox1.Text += "Task:" + reader(1).ToString() + "Date:" + dt1 + vbNewLine
MsgBox("Task:" + reader(1).ToString() + "Date:" + dt1 + vbNewLine)
End If
End While
reader.Close()
End Using
End Sub
End Class
输出:
当我点击按钮弹出窗口时会显示,数据也会添加到文本框中。
when I click on button popup will display and data will also added to textbox.
它将检查表中的所有数据。
it will check all the data in the table.
问候
Deepak
这篇关于VB代码,用于为数据库中列出的任务创建弹出提醒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!