RSS Forums RSS

search record from database

Reply
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

  #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
AddThis Social Bookmark Button
Reply With Quote  
Posts: 43
Reputation: reach_yousuf is an unknown quantity at this point 
Solved Threads: 5
reach_yousuf reach_yousuf is offline Offline
Light Poster

Re: search record from database

  #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

Public Function LoadData(ByVal StrQuery As String) As DataSet
        Try
            Dim con As New MySqlConnection(GetConnection.ToString)
            Dim cmd As New MySqlCommand(StrQuery, con)
            Dim ds As New DataSet
            Dim da As New MySqlDataAdapter(cmd)

            
            If con.State = ConnectionState.Open Then
                con.Close()
            End If
            con.Open()
            da.Fill(ds)
            If IsNothing(ds) Then
                ds = Nothing
                Return ds
            Else
                Return ds
            End If

        Catch ex As Exception
            Throw ex
        End Try
        
    End Function

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

dim ds as new dataset

ds = LoadData(strQuery )

grid.datasource = ds
grid.databind()

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

Only community members can participate in forum threads. You must register or log in to contribute.



Views: 502 | Replies: 1 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:32 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC