0

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;
    }
}
Anirudh
  • 581
  • 5
  • 14
  • 32
  • If you need to replace OleDb.4.0 (just because your app now runs in 64bit mode) then look at [Microsoft Access Database Engine](http://www.microsoft.com/en-us/download/details.aspx?id=13255) – Steve Apr 17 '15 at 21:38
  • @steve: Thanks. I had seen that link earlier but I was just curious about the changes required in my source. looks like I have to rewrite entire business logic??? – Anirudh Apr 17 '15 at 21:41
  • If really are up to this task then I suggest to switch to Sql Server and not to CSV files. ([The LocalDB version is free and simple to install](http://stackoverflow.com/questions/9655362/localdb-deployment-on-client-pc)) – Steve Apr 17 '15 at 21:47

0 Answers0