CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 1999
    Location
    Singapore
    Posts
    18

    Searching for record

    I'm working on a project that requires searching of a record in a database table. This is to be done using SQL, "select * from table where criteria = (user_input)". Is this possible, or are there any alternatives?


  2. #2
    Join Date
    Aug 1999
    Location
    India-Delhi
    Posts
    106

    Re: Searching for record

    Lynn,
    "Select *..... Where user input" is a good method to use.
    Only thing is - be careful while making the SQL string. The "'" sign should be used where you search for string, you can use the * and like keywords if want to search the string within a string.
    I just give a small example
    Lets us say in text1 control user typed the word "san". Now you wish to search the word in a string field called Xname then the search will be

    mySql = "Select * from mydb where Xname like *" & trim(text1.text) & "*'"
    'to find the exact text
    mySql = "Select * from mydb where Xname = '" & trim(text1.text) & "'"




    regards,


    Santulan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured