Dim Upath As String = "~/Uploads/" + CDate(Today.Date).ToString("yyyyMMdd") Dim excelPath As String = Server.MapPath(Upath + "/BKP/") + Path.GetFileName(FileUpload1.PostedFile.FileName) FileUpload1.SaveAs(excelPath) Dim csvPath As String = Server.MapPath(Upath) + "/" + Path.GetFileNameWithoutExtension(FileUpload1.PostedFile.FileName) + ".csv" Dim stream As FileStream = File.Open(excelPath, FileMode.Open, FileAccess.Read) Dim excelReader As IExcelDataReader = ExcelReaderFactory.CreateBinaryReader(stream) 'Dim excelReader As IExcelDataReader = ExcelReaderFactory.CreateOpenXmlReader(stream) excelReader.IsFirstRowAsColumnNames = True Dim result As DataSet = excelReader.AsDataSet() Dim csvdata As String = "" Dim row_no As Integer = 0 Dim DT As DataTable DT = result.Tables(0) ''HERE I AM OBJECT REFERENCE ERROR GridView1.DataSource = DT excelReader.Close()
result
Tables
Tables(0)
null
Dim result As DataSet = excelReader.AsDataSet() ' you create the variable result, but it does not refer to anything. Dim csvdata As String = ""Dim row_no As Integer = 0 Dim DT As DataTableDT = result.Tables(0) ''HERE I AM OBJECT REFERENCE ERROR - because result does not point to any tables.
Dim DT As New DataTable
Dim DT As DataTable DT = result.Tables(0) ''HERE I AM OBJECT REFERENCE ERROR
DT
DataTable
Nothing
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)