Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

hi create one database for example student database.

GridView column such as

name id mark

ravi 101 98
mohan 102 97
.... .. ..
.... ... ...

i want i create anther form one textbox and searchButton

the textbox i type the name as ravi and click the SearchButton display all the details of ravi.
Posted
Comments
Mantu Singh 28-Feb-12 3:14am    
pls clarify more whether you want to search in the data grid or database

Dim aaa as Integer
Private Sub sea_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sea.Click
Try
aaa = TextBox1.Text
con.Open()
Dim da As New OleDbDataAdapter("select * from products where code=" & (TextBox1.Text), con)
Dim dt As New DataTable
da.Fill(dt)
If dt.Rows.Count <= 0 Then
MsgBox("This Number Does Not Exist", MsgBoxStyle.DefaultButton1, "Not Exist")
Else
DataGridView1.DataSource = dt
code.Text = dt.Rows(cur)(1).ToString
pro.Text = dt.Rows(cur)(2).ToString
com.Text = dt.Rows(cur)(3).ToString
buy.Text = dt.Rows(cur)(4).ToString
sell.Text = dt.Rows(cur)(5).ToString
date1.Text = dt.Rows(cur)(6).ToString
End If
Catch ex As Exception
MsgBox("Enter a correct code")
Finally
con.Close()
End Try
End Sub
Dim i As Integer
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick

Try
con.Open()
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter
da = New OleDbDataAdapter("select * from Products", con)
da.Fill(dt)

i = DataGridView1.CurrentRow.Index
code.Text = DataGridView1.Item(1, i).Value
pro.Text = DataGridView1.Item(2, i).Value
com.Text = DataGridView1.Item(3, i).Value
buy.Text = DataGridView1.Item(4, i).Value
sell.Text = DataGridView1.Item(5, i).Value
date1.Text = DataGridView1.Item(6, i).Value

Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()

End Sub
 
Share this answer
 
hi,

try this...

VB
dim qry = From therow as DataGridViewRow In DataGridView1.Rows,
          thecell as DataGridViewCell In therow.Cells 
          Where thecell.value.ToString = TextBox1.Text Select thecell

Dim cells()=qry.ToArray

now use the cells()...

any doubt reply me...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900