hello every body
iam 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 usig student idno.
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
so iwant standered code to read particular records based on student nuber as
my choice.
plz help me.......
my text file like this
|-----------------------------------------------|
| 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. |
-|
| stdid stdname class |
| 1 raheem mca |
| 2 sudheer mca |
--------------------------------------------------
|
My code is
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 < 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);
}
}
}