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.O leDb.4.0;D ata Source={0};Extended Properties=""Text;HDR=Yes; FMT=Delimi ted""",
System.IO.Path.GetDirector yName(file Path));
using (OleDbConnection conn = new OleDbConnection(connection String))
{
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
"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.O
System.IO.Path.GetDirector
using (OleDbConnection conn = new OleDbConnection(connection
{
string command = String.Format(
@"SELECT * FROM {0}", System.IO.Path.GetFileName
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[
return ds;
}
}
}
works.jpg
fails.jpg
DEDUCTIONS.CSV
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.