i read file through c# and the format of file is this.
INPUT FILE
00001740, 0.125, 0, able
00001740, 0.125, 0, unable
00002098, 0, 0.75, country
00002312, 0, 0, love
i want this file in MYSQL Database. i write the code which store each line in each ROW of database. but the following code WRITE only the first line of the text file
private void button1_Click(object sender, EventArgs e)
{
string MyConString = "server=localhost;" +
"database=zahid;" + "password=zia;" +
"User Id=root;";
MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
connection.Open();
StreamReader reader = new StreamReader("D:\\out.txt");
string line;
while ((line = reader.ReadLine()) != null)
{
string[] parts = line.Split(',');
command.CommandText = "insert into score(POS_ID,Pos,Neg,Word) values('" + parts[1] + "','" + parts[2] + "','" + parts[3] + "','" + parts[4] + "')";
Reader = command.ExecuteReader();
}
}
this code return only the First line , but i want that all lines of text file store in the Database . thanks in advance