Ankit Agarwal

Ankit Agarwal

  • NA
  • 379
  • 248.1k

how to import updated pipe separated text file's data using?

Sep 2 2013 1:57 AM
Hello,

I am using this code for export datagridview's data to pipe separated txt file.

StreamWriter sw = new StreamWriter(filePath, false);

         int iColCount = dataTable.Columns.Count;

         //for (int i = 0; i < iColCount; i++)
         //{
         //    sw.Write(dataTable.Columns[i]);

         //    if (i < iColCount - 1)
         //    {
         //        sw.Write("|");
         //    }
         //}
         //sw.Write(sw.NewLine);



         foreach (DataRow row in dataTable.Rows)
         {
             for (int i = 0; i < iColCount; i++)
             {
                 if (!Convert.IsDBNull(row[i]))
                 {
                     sw.Write(row[i].ToString());
                 }
                 if (i < iColCount - 1)
                 {
                     sw.Write("|");
                 }
             }
             sw.Write(sw.NewLine);
         }
         sw.Close();

It's code running successfully, i mean to say, successfully exported in pipe separated file but when we update any value in it's export's file and then import same file in to the database using c# .net so,my database did not update from this file.

Please help me.

Thanks in Advance

Ankit Agarwal
Software Engineer

Answers (5)