943,671 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 903
  • ASP.NET RSS
Nov 22nd, 2008
0

search record from database

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
krany18 is offline Offline
19 posts
since Nov 2008
Nov 23rd, 2008
0

Re: search record from database

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

ASP.NET Syntax (Toggle Plain Text)
  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

ASP.NET Syntax (Toggle Plain Text)
  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.
Reputation Points: 12
Solved Threads: 38
Junior Poster
reach_yousuf is offline Offline
194 posts
since Sep 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: oledbDataAdapter.update exception: No value given for one or more required parameter
Next Thread in ASP.NET Forum Timeline: C# equivalent for the PHP strip_tags()





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC