关于vb.net和access的数据查询,大仙帮帮我吧

2024-12-30 13:07:20
推荐回答(2个)
回答1:

Imports System.Data.OleDb

Public Class Test
Dim c As cls_conn '这个是我自己的connection (用你自己的)
Dim sql As OleDbCommand

Private Sub Test_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
c = New cls_conn '这个是我自己的connection (用你自己的)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
c = New cls_conn
sql = New OleDbCommand("Select * from tbl WHERE ddate = @ddate", c.pconn) '连接数据库,ddate是你的日期
sql.Parameters.Add("ddate", OleDbType.Date).Value = DateTimePicker1.Value
Dim dr As OleDbDataReader = sql.ExecuteReader

If dr.Read Then
MsgBox("ok") '如果发现你要 textbox1.text = dr("文章“)
Else
MsgBox("no ok ") '如过没有发现你显示没有。
End If
dr.Close()
End Sub
End Class

一个datetimepicker
一个textbox1(multiline)的
一个button1

回答2:

Exit Sub