Link to home
Start Free TrialLog in
Avatar of finance_teacher
finance_teacher

asked on

C# -- small DataSet issue

How can I fix the below so the
"CheckViewDedcode" column
populates correctly ?

Steps
 1. run below
 2. works.jpg shows column "CheckViewDedcode" has all values
 3. change attached "DEDUCTIONS.CSV" cell D4 from alpha to number
 4. run below again
 5. fails.jpg shows column "CheckViewDedcode" do NOT have all values

        private DataSet ReadFile(string filePath)
        {
            string connectionString = String.Format(
                @"Provider=Microsoft.Jet.OleDb.4.0;Data Source={0};Extended Properties=""Text;HDR=Yes;FMT=Delimited""",
                System.IO.Path.GetDirectoryName(filePath));

            using (OleDbConnection conn = new OleDbConnection(connectionString))
            {
                string command = String.Format(
                    @"SELECT * FROM {0}", System.IO.Path.GetFileName(filePath));
                using (OleDbDataAdapter adapter = new OleDbDataAdapter(command, conn))
                {
                    DataSet ds = new DataSet("Temp");
                    adapter.Fill(ds);

                    // Loop through the data table and change names like "Doe,John" to "John Doe"
                    //foreach (DataRow row in ds.Tables[0].Rows)
                     //   row[0] = Regex.Replace((string)row[0], @"([^,]*),([^,]*)", "$2 $1");

                     return ds;
                }
            }
        }
works.jpg
fails.jpg
DEDUCTIONS.CSV
ASKER CERTIFIED SOLUTION
Avatar of topdog770
topdog770
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of MikeToole
MikeToole
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial