The Code is as follows:
Public partial class Form1: Form
{
Public Form1 ()
{
InitializeComponent ();
String strsql = @ "server =.; uid = sa; pwd = sa; database = Northwind ";
SqlConnection my_Conn = new SqlConnection (strsql );
My_Conn.Open ();
String str_ SQL = "select * from employeesTable ";
// DataSet my_Dataset = new DataSet ();
// SqlCommand my_comm = new SqlCommand (str_ SQL, my_Conn );
// SqlDataAdapter SQL _Adapter = new SqlDataAdapter (str_ SQL, my_Conn );
// SQL _Adapter.Fill (my_Dataset, "employeesTable ");
SqlCommand my_Comm = new SqlCommand (str_ SQL, my_Conn );
SqlDataReader reader = my_Comm.ExecuteReader ();
While (reader. Read ())
{
ListViewItem viewitem = new ListViewItem (reader [0]. ToString ());
Viewitem. ImageIndex = 0;
Viewitem. SubItems. Add (reader [1]. ToString ());
Viewitem. SubItems. Add (reader [2]. ToString ());
ListView1.Items. Add (viewitem );
}
}
Private void BtnSearch_Click (object sender, EventArgs e)
{
Int mystartindex = 0 ;///
Int Count = Convert. ToInt32 (this. textBox1.Text );
ListViewItem Item = listView1.FindItemWithText (textBox1.Text, true, mystartindex );
Try
{
If (textBox1.Text! = Null)
// If (Count> = listView1.Items. Count)
{
ListView1.Focus ();
Item. Selected = true;
Mystartindex = mystartindex + 1;
}
Else
{
MessageBox. Show ("no data you want ");
}
}
Catch (Exception ex)
{
MessageBox. Show (ex. Message );
}
}
}
}