I have been asked to port a WinForms app that uses the MVP pattern over to a webpage. The app, amongst other things, uploads a CSV file to a DataTable and then does some work.
The CSV file is uploaded to the server OK and then read with the following code
string connectionString = @"Driver={Microsoft Text Driver (*.txt; *.csv)};Extensions=asc,csv,tab,txt;Persist Security Info=False;Dbq=C:\Temp\";
//check that file exists and in correct format
if (File.Exists(this.WorkingFileName))
{
using (OdbcConnection connection = new OdbcConnection(connectionString))
{
// Determine number of rows
string selectCount = "select count(*) from [MyFile.csv]");
using (OdbcCommand command = new OdbcCommand(selectCount, connection))
{
connection.Open();
}
}
}
at this point I get the error:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Now the code works fine in WinForms but fails on the web. Is there something I need to change in IIS, my config file or something else to get this code to work? Or is there something more fundamental I need to do?
Update
OK so I worked out what was different between my two code versions: The WinForms version was running as 32-bit, as soon as I changed it to 64-bit it threw the same error. See: 32-bit Text drivers (Microsoft Access , Microsoft Excel and Text files ) from a 64 bit application on windows 7
To fix things I installed the Access 64-bit drivers from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=13255 but I still get the same error.
If I check my ODBC Data Source Administrator I can see "Microsoft Access Text Driver (*.txt, *.csv) | 14.00.47600.1000 | Microsoft Corporation | ACEODBC.dll
So it looks like they're installed OK, so why would it still be failing?