我使用VB.net和MS Access创建了以下内容。这里当我在文本框中输入书名时,它会自动对数据网格视图中的值进行排序。
代码
Private Sub frmBookSearch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtBookSearch.Focus()
da = New OleDbDataAdapter("SELECT [BookID], [Title], [Author], [Publisher], [Category], [Price], [ISBN] FROM tblBooks", myConnection)
da.Fill(ds, "tblBooks")
Dim view1 As New DataView(tables(0))
source1.DataSource = view1
DataGridView1.DataSource = view1
DataGridView1.Refresh()
End Sub
Private Sub txtBoxNo_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtBookSearch.KeyPress
source1.Filter = String.Format("[Title] LIKE'" & txtBookSearch.Text & "%'")
DataGridView1.Refresh()
End Sub
现在我正在使用BV.Net和SQL服务器创建另一个应用程序。 在这里,我想在会员ID文本框中输入会员ID时填写会员名称文本框,并在输入书籍Acc no textbox时填写书名称文本框。
表格详情如下
tblMember
-----------
membershipNo INT
firstName VARCHAR (50)
tblBookDetail
------------
accessionNo INT
title VARCHAR(300)
提前致谢。
Private Sub txtMemID_TextChanged(sender As Object, e As EventArgs) Handles txtMemID.TextChanged
Using comBookLendMember As New SqlCommand("SELECT membershipNo, firstName FROM tblMember ORDER BY membershipNo", con)
End Using
End Sub