how to get records entered in text file based on key value
<p>I am developing windows project using c#. I have to import text file records into sqlserver 2005 db.
My question  is
 I want to read records from text file using student Idno.</p>

<p>I have an idea of read exact value from  text file using strings that is finding student no:1001  value .
 I want to read every student record based on particular student no? not for 1001</p>

<p>so I want standered code to read particular records based on student number    as
 my choice.
plz help me.......</p>

<p>my text file like this</p>

<pre>
      |-----------------------------------------------|
      |            student no:1001                    | 
      |           address:ongole,A.P,                 | 
      |           hyderabad,india.                    | 
      | ----------------------------------------------| 
      |  stdid stdname   class                        |
      |   1     raheem   mca                          |
      |   2     sudheer  mca                          |
      | ----------------------------------------------|
      | student no:1001                               | 
      |   address:ongole,A.P,                         |
      |           hyderabad,india.                    | 
     -|--------------------------------------------   | 
      |  stdid stdname   class                        |
      |   1     raheem   mca                          | 
      |   2     sudheer  mca                          |
      | ----------------------------------------------|
      |     student no:1002                           |
      |   address:ongole,A.P,                         |
      |           hyderabad,india.                    |
      ------------------------------------------------|-
      |       student no:1003                         |
      |   address:ongole,A.P,                         |
      |           hyderabad,india.                    | 
     -|---------------------------------------------- |
</pre>

<p>My code is </p>

<pre><code>private void BtnImpstrm_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
            string f = openFileDialog1.FileName;
            StreamReader sr = new StreamReader(f);
            string s = sr.ReadToEnd();
            MessageBox.Show(s);
            sr.Close();
            str =s.Split('\n');
            for (int i = 0; i &lt; str.Length; i++)
            {
                if (str[i].ToString().Trim().ToUpper().Contains("Student NO :  1001"))
                {
                    string[] words = str[i].Split(' ');
                    string output = words[word no].ToString().Trim();
                    string rec1 =str[line no].ToString().Trim();
                    string rec2 = str[line no].ToString().Trim();
                    MessageBox.Show(output);
                    MessageBox.Show(rec1);
                    MessageBox.Show(rec2);

                }
            }

        }  
</code></pre>
