search mysql database with textbox in asp.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajsrmc
    New Member
    • Jan 2010
    • 9

    search mysql database with textbox in asp.net

    Hello pals
    i have connected mysql table in gridview, how to do search by using the particular word from the text box and suggest any ways to get the result in grid view
    Please send some pseudocodes(vb codes)
    any sorts of help will be really useful
    Thanks in advance
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    This is a SQL question, not a VB question. What you need to do is retrieve the text entered by the user from the TextBox and then use that in the WHERE part of your SQL query.

    Check out this article on the SqlCommand.Para meters Property...

    For example (please note that this code is just an example....it will Not work without modification and some additional code):
    Code:
    Dim connectionStr As String = "....the connectionString..."
    Dim sqlCommandText As String = "SELECT * FROM my_table WHERE the_table_id = @theValue"
    
    Dim command As New SqlCommand(sqlCommandText, connectionStr)
    
    command.Parameters.Add("@theValue", SqlDbType.Int)
    command.Parameters("@theValue").Value = myTextBox.Text
    -Frinny

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      Database How-to parts 1 and 2
      Database tutorial Part 1
      Database tutorial Part 2

      Comment

      Working...