Below is the source from an old environment and I need to deploy this in new windows server 2014.
I initially thought of deploying the code AS IS but later I thought about Microsoft.Jet.oledb support options in the coming years and hence decided to modify the code such that I just manipulate (or change) only the connection settings and then letter the DATASETS as it is in the current code.
For example, there is "dsTextFile" (dataset) that is shown in below source which is used extensively in the entire source by referencing the column-name.
What I have tried: I have actually tried just reading it as a CSV file using streamreader but I need to make lot of changes as far getting right data based on column-name or even parsing further.
Many thanks.
private bool LoadTextFile(string textFilePath, out string errorInfo) {
errorInfo = String.Empty;
try {
string textFileFolder = (new System.IO.FileInfo(textFilePath)).DirectoryName;
string textConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + textFileFolder + ";" +
"Extended Properties=\"text;HDR=No;FMT=Fixed\";";
OleDbConnection textConnection = new OleDbConnection(textConnectionString);
textConnection.Open();
textFilePath = (new System.IO.FileInfo(textFilePath)).Name;
string selectCommand = "select * from " + textFilePath;
OleDbCommand textOpenCommand = new OleDbCommand(selectCommand);
textOpenCommand.Connection = textConnection;
OleDbDataAdapter textDataAdapter = new OleDbDataAdapter(textOpenCommand);
Console.WriteLine("Trying to set textDataAdapter");
int rows = textDataAdapter.Fill(dsTextFile); //This is where error is coming.
Console.WriteLine("detail rows being filled");
textConnection.Close();
textConnection.Dispose();
return true;
}
catch (Exception ex_load_text_file) {
Console.WriteLine("error in loadTextFile is " + ex_load_text_file.Message.ToString());
return false;
}
}