如何通过输入数据从数据库中获取另一个字段?

时间:2017-11-24 15:56:19

标签: .net sql-server vb.net

我使用VB.net和MS Access创建了以下内容。这里当我在文本框中输入书名时,它会自动对数据网格视图中的值进行排序。 Datagrid filterd by textbox value

代码

 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)

SQL Server and VB.Net

提前致谢。

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

0 个答案:

没有答案