search record from database

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2008
Posts: 19
Reputation: krany18 is an unknown quantity at this point 
Solved Threads: 0
krany18 krany18 is offline Offline
Newbie Poster

search record from database

 
0
  #1
Nov 22nd, 2008
hai friends ,,

in monster/naukri we have a search button is there.using that we can search the record from there.
in my project also we have a registration form .
if we wants any customer details just we enters the customer id or name that customer details can retrieved.
i want the code to do like that .i am thinking from 4 days onwards but i am not getting .i am trying using the select command but it is retrieved
please send me a correct to that
Thanks & Regards,

A.Kranti Kumar
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 66
Reputation: reach_yousuf is an unknown quantity at this point 
Solved Threads: 12
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 Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC