View Single Post
Join Date: Sep 2007
Posts: 68
Reputation: reach_yousuf is an unknown quantity at this point 
Solved Threads: 13
reach_yousuf reach_yousuf is offline Offline
Junior Poster in Training

Re: search record from database

 
0
  #2
Nov 23rd, 2008
Pls. use SQL query viz

strQuery = "Select * from customers where customer name like '%" textbox1.text &" %'"

Pls. make sure to change your approriate db connection string

  1. Public Function LoadData(ByVal StrQuery As String) As DataSet
  2. Try
  3. Dim con As New MySqlConnection(GetConnection.ToString)
  4. Dim cmd As New MySqlCommand(StrQuery, con)
  5. Dim ds As New DataSet
  6. Dim da As New MySqlDataAdapter(cmd)
  7.  
  8.  
  9. If con.State = ConnectionState.Open Then
  10. con.Close()
  11. End If
  12. con.Open()
  13. da.Fill(ds)
  14. If IsNothing(ds) Then
  15. ds = Nothing
  16. Return ds
  17. Else
  18. Return ds
  19. End If
  20.  
  21. Catch ex As Exception
  22. Throw ex
  23. End Try
  24.  
  25. End Function

The above will return the dataset. bind this dataset to your grid

  1. dim ds as new dataset
  2.  
  3. ds = LoadData(strQuery )
  4.  
  5. grid.datasource = ds
  6. grid.databind()

Pls. mark as solved if it helps you.
Last edited by reach_yousuf; Nov 23rd, 2008 at 1:25 am.
Yousuf
Software Developer
Reply With Quote