jxharding
asked on
cant load CSV into dataset - IE displays file does not exist, but it does - code supplied, prob small error
it's a simple task, use asp.net to load a csv file into a dataset.
the file exists : if i copy and paste the "c:\inetput\wwwroot\MyFold er\MyApp.c sv" into browser, i access the file.
still i get the error file does not exist
i tried all the posts i could find, all of them use c# but the usage is the same.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim MyCommand As System.Data.OleDb.OleDbDat aAdapter
Dim MyConnection As System.Data.OleDb.OleDbCon nection
MyConnection = New System.Data.OleDb.OleDbCon nection( _
"provider=Microsoft.Jet.OL EDB.4.0; data source=" & Server.MapPath("/MyFolder/ MyFile.csv ") & ";Extended Properties=text")
' Select the data from Sheet1 of the workbook.
MyCommand = New System.Data.OleDb.OleDbDat aAdapter(" select * from [Sheet1$]", MyConnection)
'DS = New System.Data.DataSet
MyCommand.Fill(Extension1) '>>>>>>>> BOMBS OUT HERE
MyConnection.Close()
Me.DataGrid1.DataSource = Extension1
Me.DataGrid1.DataBind()
End Sub
Contents of CSV File : (No headers)
Barnabas,A,7528
Brains, Eric,7534
Please help me load this csv into dataset.
thanks!
the file exists : if i copy and paste the "c:\inetput\wwwroot\MyFold
still i get the error file does not exist
i tried all the posts i could find, all of them use c# but the usage is the same.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim MyCommand As System.Data.OleDb.OleDbDat
Dim MyConnection As System.Data.OleDb.OleDbCon
MyConnection = New System.Data.OleDb.OleDbCon
"provider=Microsoft.Jet.OL
' Select the data from Sheet1 of the workbook.
MyCommand = New System.Data.OleDb.OleDbDat
'DS = New System.Data.DataSet
MyCommand.Fill(Extension1)
MyConnection.Close()
Me.DataGrid1.DataSource = Extension1
Me.DataGrid1.DataBind()
End Sub
Contents of CSV File : (No headers)
Barnabas,A,7528
Brains, Eric,7534
Please help me load this csv into dataset.
thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes, the web server is my box
'c:\inetpub\wwwroot\MyFold er\MyFile. csv' 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.
but if i copy that section , i access the file.
this is a really non descriptive error message from asp.
so should the code work in fact then?
'c:\inetpub\wwwroot\MyFold
but if i copy that section , i access the file.
this is a really non descriptive error message from asp.
so should the code work in fact then?
Can the OLEDB Provider accept CSV files???
I dont think Jet can do that...
ASKER
heh I was right:
conn_excel_str = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq="
+ HttpContext.Current.Server .MapPath(" .//" + csv_store_read);
//Server.MapPath(".//" + csv_store_read)
//Path mapped to csv file temp stored on the server
you load the csv through this driver not the Jet Driver
conn_excel_str = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq="
+ HttpContext.Current.Server
//Server.MapPath(".//" + csv_store_read)
//Path mapped to csv file temp stored on the server
you load the csv through this driver not the Jet Driver
ASKER
well its still not working
is there any other method of text that you could help me with to load this file into the dataset? i dont know how to se the darn microsoft text driver in a vb.net connection string.
is there any other method of text that you could help me with to load this file into the dataset? i dont know how to se the darn microsoft text driver in a vb.net connection string.
ASKER
This post did not help at all. I accepted answer because it is going to stand still. Im pursuing another question.
Thanks
Thanks
i was researching the answer, i will post the answer nonetheless.
2. Virtual directories means that the actual file location may not under wwwroot.
Server.MapPath("~/MyFolder
do the trick.