顯示詳細形式我有一個名爲「搜索」與2個文本框,datagridview的和按鈕移到形式。當我輸入任何關鍵詞,例如我想進入第一個文本框[「txtemployee_search」]的名稱,它過濾它綁定到當我選擇名稱即時尋找員工table.so DataGridView的[dgvemployee]項目,它顯示了在第二個文本框[「txtemp_search_selection」。但我的問題是,我需要顯示或打開第二個形成含有如姓名,年齡,性別,照片,電話等詳細資料這是在第二個文本框當與名稱我點擊按鈕。即時通訊使用VB 2008和SQL Server 2005.我需要幫助PLS!下面基於文本框的值和一個按鈕
是我的代碼
Imports System.Data.SqlClient
Public Class employee_search
'THE CODE TO SEARCH DATAGRID WHILE TYPING INTO FIRST TEXTBOX
Private Sub txtemployee_search_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtemployee_search.TextChanged
Dim keywords As String = txtemployee_search.Text
Dim con As SqlConnection = New SqlConnection("Data Source=oheneba;Initial Catalog=brainiac;Persist Security Info=True;User ID=sa;Password=***********")
' Use wildcard
Dim cmd As SqlCommand = New SqlCommand("SELECT * FROM Employee WHERE Full_Name Like '%" & keywords & "%' ", con)
' or Where Full_Name='" & keywords & "'
con.Open()
Dim myDA As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim myDataSet As DataSet = New DataSet()
myDA.Fill(myDataSet, "Employee")
dgvemployee.DataSource = myDataSet.Tables("Employee").DefaultView
con.Close()
End Sub
「的代碼顯示所選的DataGridView項目插入第二個文本框
Private Sub dgvemployee_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvemployee.CellContentClick
Dim dgv As DataGridView = CType(sender, DataGridView)
Dim thisCell As DataGridViewCell = dgv.SelectedCells(0)
Dim selCell As Integer = thisCell.ColumnIndex
txtemp_search_selection.Text = dgvemployee.CurrentRow.Cells(selCell).Value.ToString()
End Sub
觀看SQL注入。 – APrough