I have written a code to extract data from different text files. I am reading only 3 values from all the different text files. Now i want to write them in database table.
please tell me how to do that through c# coding???
private void button1_Click(object sender, EventArgs e)
{
string to_date = dateTimePicker2.Value.ToString("yyyy/MM/dd");
Console.WriteLine("a");
string[] name = new string[18] {"005","006","008","015","017","019","024","032","034","035","037","038","039","041","049","050","051","014"};
for (int i = 0; i < name.Length; i++)
{ conairdata(to_date, name[i]); }
label9.Text = " Completed";
label9.Refresh();
Console.WriteLine("d");
}
public void conairdata(string to_date , string name)
{
Console.WriteLine("e");
string path = "H:\\Su\\air\\reporting\\mdata"+name+".rpt";
int nofcol = 0;
int nofrows = File.ReadLines(path).Count();
StreamReader sReader = new StreamReader(path);
string line = sReader.ReadLine();
string[] tileNo = line.Split(',');
nofcol = tileNo.Count();
progressBar1.Minimum = 1;
progressBar1.Maximum = nofrows;
progressBar1.Value = 1;
progressBar1.Step = 1;
sReader.Close();
Console.WriteLine("f");
sReader = new StreamReader(path);
DateTime datum, dt1,dt2, dt3;
for (int y = 1; y < nofrows; y++)
{
line = sReader.ReadLine();
tileNo = line.Split(',');
string k = tileNo[19];
string l = tileNo[3];
string s = tileNo[0];
try
{
string x = s.Substring(s.IndexOf("(") + 1, (s.IndexOf(")") - s.IndexOf("(") - 1)).Replace(".", "-");
datum = Convert.ToDateTime(x);
dt1 = DateTime.Parse(Convert.ToString(datum));
logger(dt1, l, k);
}
catch(Exception)
{ }
if (y != nofrows)
{ progressBar1.PerformStep(); }
}
label9.Text = " Now processing... Please wait";
label9.Refresh();
sReader.Close();
}