Load txt file to Grid (comma separated value)

Hello Gurus,

I need your help. I have a text file (NL-test.txt attached) which has values delimited with comma. When i load the program using following code some of the values are missing. I am attaching the text file and also the screenshot with missing info marked in RED color. Please help.


DataTable dt = new DataTable();
            string strFileName = "C:\\NL_test.txt";

            string strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "C:\\" + ";Extended Properties='text;HDR=Yes'";
            string CommandText = "select * from " + strFileName;

            OleDbConnection conn = new OleDbConnection(strConnString);
            conn.Open();

            OleDbDataAdapter da = new OleDbDataAdapter(CommandText, conn);
            da.Fill(dt);
            dataGridViewX1.DataSource = dt;
            dataGridViewX1.Refresh();

Open in new window

txt-to-grid.jpg
NL-test.txt
shanvidhyaAsked:
Who is Participating?
 
masterpassCommented:
0
 
shanvidhyaAuthor Commented:
Thanks masterpass  for helping solve this problem.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.