find and populate datagridview with textboxes

  • Thread starter Thread starter Omi4u
  • Start date Start date
O

Omi4u

Guest
dear all

please check the attached image . i have a module for leather stock . now i have two tables

leatherstock and leatherstock_join in ms sql.


1455808.jpg



now what i need is whenever user enter LSID no or Lot no in circled textbox, they must get related record if available and populate in textboxes and datagridview columns. datagridview is unbound


i tried one code but it not working and making own columns in datagridview infect not populating textboxes .

here are the code . textbox1.text is to search record by using LSID no (circled)


Public Sub FilterData(ByVal valueToSearch As String)



'SELECT * From Users WHERE CONCAT(fname, lname, age) like '%F%'
' Dim searchQuery As String = "SELECT * From items WHERE itemname like '%" & valueToSearch & "%'"

Dim searchQuery As String = "SELECT * From leatherstock WHERE LSID like '%" & valueToSearch & "%'"
Dim command As New SqlCommand(searchQuery, connectionx)
Dim adapter As New SqlDataAdapter(command)
Dim table As New DataTable()
adapter.Fill(table)
DataGridView1.DataSource = table
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\










End Sub


Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress





If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then

FilterData(TextBox1.Text)

End If


End Sub

Continue reading...
 
Back
Top