开发者

CSV files and OLEDB in VB.net - Exception with no info

开发者 https://www.devze.com 2023-02-16 15:28 出处:网络
I\'m trying to parse a user-submitted csv file in ASP.NET with VB.Here is my function: Public Function getData() As DataSet

I'm trying to parse a user-submitted csv file in ASP.NET with VB. Here is my function:

Public Function getData() As DataSet
        Dim conn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetTempPath() + ";Extended Properties=""Text;HDR=No;FMT=Delimited"""

        Dim cn As New OleDbConnection(conn)
        Dim cmd As New OleDbCommand("SELECT * FROM " + sourceFile, cn)
        Dim da As New OleDbDataAdapter(cmd)

        cn.Open()

        Dim dt As New DataSet()

        da.Fill(dt)

        cn.Close()
        Return dt
    End Function

the error I get is:

System.Data.OleDb.OleDbException was unhandled by user code

ErrorCode=-2147467259 Message=IErrorInfo.GetDescription failed with E_FAIL(0x80004005). Source=System.Data StackTrace: at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, Command开发者_StackOverflow社区Behavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at SuperSMITH.CSVReader.getData() in C:\Projects\Allied\App_Code\CSVReader.vb:line 29 at tools_Step2.uplFile_FileUploadComplete(Object sender, FileUploadCompleteEventArgs e) in C:\Projects\Allied\tools\Step2.aspx.vb:line 58 at DevExpress.Web.ASPxUploadControl.ASPxUploadControl.OnFileUploadComplete(FileUploadCompleteEventArgs e) at DevExpress.Web.ASPxUploadControl.ASPxUploadControl.RaiseFileUploadComplete(UploadedFile uploadedFile, String& errorText, String& callbackData) at DevExpress.Web.ASPxUploadControl.ASPxUploadControl.Validate() InnerException:

The error comes up at the da.fill(dt) line.

Any suggestions?


Every search result that comes up says it has to do using reserved keywords in the CSV file or in the SELECT statement. What's the value of sourceFile?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号