Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

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

C#
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
Posted
Updated 1-Sep-13 19:53pm
v2
Comments
Pheonyx 2-Sep-13 3:15am    
What code do you use to import the data?
[no name] 2-Sep-13 3:16am    
N'BULK INSERT dbo.BackUp_BAN_ItemDataMaster FROM ''' +
@UUSItemMasterPath +
N''' WITH (FIELDTERMINATOR = ''|'', ROWTERMINATOR = ''\n'')'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900