المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : ASP C# WebSite to load a simple CSV File



C# Programming
12-07-2010, 09:40 PM
Hi All,

I want to have an ASP C# WebSite that loads a simple CSV File and present it in a GridView control (at least for a start).

I already have a piece of code that do almost all of the work, what i miss / unable to make it work is setting correctly the "Data Source".

The CSV file that I want to load is located on different server in the network (path is "\\td47vc\public\Joe\ASP\Test").

Here is the code I wrote:

public DataSet GetCSVFile(string fileName)
{

string pathName = "\\td47vc\\public\\Joe\\ASP\\Test";
string file = System.IO.Path.GetFileName(fileName);
OleDbConnection excelConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathName + ";Extended Properties=Text;");
OleDbCommand excelCommand = new OleDbCommand(@"SELECT * FROM " + file, excelConnection);
OleDbDataAdapter excelAdapter = new OleDbDataAdapter(excelCommand);
excelConnection.Open();
DataSet ds = new DataSet();
excelAdapter.Fill(ds);
excelConnection.Close();
return ds;
}

I get the following error:
'\\td47vc\public\Joe\ASP\Test' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

Thanks,
GorovDude