How to search in a database? RRS feed

  • Question

  • Good Day,

    I wanted to know how to implement search in a database, I tried to code some of my own using Regular Expressions found in the 101VBSamples. How to search up from the dataset and search down. Search is a very usefull function to every database especially when the records become to large.

    Thursday, September 13, 2007 5:30 AM

All replies

  • What kind of search do you need? You could use WHERE clause to do this in a case if you need to narrow down selection for the specific columns. You also could implement full-text search, but it requires different skills. You need to be more specific about what you need to accomplish


    Thursday, September 13, 2007 11:50 AM
  • Agreed with VMazur.

    If you are using a DataView, then you can set the RowFilter property to the expression you want to match, similar syntax to SQL.


    basically, here is a typical search query:


    SELECT * FROM [table] WHERE [field] = value


    this will then return back results based on that condition. You would need to execute this and either retrieve data using a SqlDataReader/OleDbDataReader and read row by row, or fill a DataTable/DataSet using the Sql or OleDb DataAdapter classes, which will contain the results after executing the query you have given to execute.

    Thursday, September 13, 2007 12:18 PM
  • Hello,

    Thanks for the reply I will try that!

    Friday, September 14, 2007 8:51 AM
  • Hello,

    I have made a software custom made to specific needs and requirements of the company I am currently working.
    The Development tool I use is Visual Studio 2005.

    I define a datasource binded to the DataGridView and it works fine. Their is already a bindingnavigator that contains the first item, previous item, next item, last item, add record, delete record, update record.

    However I wanted the user to perform search and replace in the DataGridView - when the user performs a search there are simple options that I created like:
    1. Ignore Case
    2. No Options
    3. Search Up
    4. Search Down

    These are the complete type of search I wanted to put in my application.

    I know basic SQL comands like:
    SELECT column_name FROM table_name WHERE column_name=constraints;
    et al...

    It would be highly appreciated if you can refer me some code or a weblink to peruse by.

    I had examined some code samples which I downloaded from microsoft on implementing Regular Expressions on VB.NET(101VB.NET samples) to perform search strings. I wanted more.

    Friday, September 14, 2007 9:10 AM
  • Hi ahmedilyas,

    Can you give me a sample code on how to this.


    Saturday, September 15, 2007 5:51 AM