Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Search from TextBox

$
0
0
Hi!

It's my very first time to be registered in this forum. I'm starting as a new in C#.Net world.
On my button I wrote this code below I can make a search easly through my wroten codes. But I would like to know how can I search a record from a textbox placed on my form.

thanks,
Leader2000

string searchFor = "Patel";

            int results = 0;
            DataRow[] returnedRows;

            returnedRows = ds1.Tables["Workers"].Select("last_name='" + searchFor + "'");
            //returnedRows = ds1.Tables["Workers"].Select(textBox1.Text='" + searchFor + "'");

            results = returnedRows.Length;

            if (results > 0)
            {
                DataRow dr1;

                dr1 = returnedRows[0];

                MessageBox.Show(dr1[1].ToString() + " " + dr1[2].ToString());
            }
            else
            {
                MessageBox.Show("No such Record");

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>