how?
G
gorovdude
@gorovdude
Posts
-
ASP C# WebSite to load a simple CSV File -
ASP C# WebSite to load a simple CSV FileHi 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