目前我在将csv文件导入devexpress gridview时遇到问题,当我执行代码时,显示以下错误'C:\New folder\QtimeAutomotiveByLot_new.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.
并且文件路径在我这边工作得很好。我的代码如下,有人可以指导我吗?
网
<dx:ASPxGridView ID="DetailGridx" runat="server" OnDataBinding="DetailGridx_DataBinding">
VB.net
Protected Sub DetailGridx_DataBinding(sender As Object, e As EventArgs)
Dim dt1 As New DataTable()
Dim csvFileFolder As String = "C:\New folder\QtimeAutomotiveByLot_New.csv"
'Dim csvFile As String = "QtimeAutomotiveByLot_New.csv"
Dim strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + csvFileFolder + ";Extended Properties='Text;HDR=YES;IMEX=1;';"
Dim connx As New OleDbConnection(strCon)
Dim adapter1 As New OleDbDataAdapter
connx.Open()
Dim sql As New OleDbCommand("Select * FROM [" + csvFileFolder + "]", connx)
adapter1.SelectCommand = sql
adapter1.Fill(dt1)
connx.Close()
Dim detailGrid As ASPxGridView = CType(sender, ASPxGridView)
Dim RowLotID As String = TryCast(sender, ASPxGridView).GetMasterRowFieldValues("LOTID")
Dim ddata As DataView = New DataView(dt1)
ddata.RowFilter = "LOTID = '" + RowLotID + "'"
detailGrid.DataSource = ddata
detailGrid.DataBind()
End Sub