Hi
I have this function which will fill a DataTable with data from SqlDataReader: (I had simplified the function to show the error only)
Function GetTable(ByVal sqlReader As SqlDataReader) As DataTable
Dim schemaTable As DataTable
Dim outputTable As New DataTable()
Dim dcColumn As DataColumn
Dim drRow As DataRow
schemaTable = sqlReader.GetSchemaTable()
Response.Write("Count :" & schemaTable.Rows.Count)
Return outputTable
End Function
The function is called this way:
RsDataDT = GetTable(RsData)
Then I hit an error: Object reference not set to an instance of an object. On this line 'Response.Write("Count :" & schemaTable.Rows.Count)'
But if I do not assign the DataTable thru the function GetTable, then I do not get the error, as below:
Dim RsChartDT as DataTable
RsDataDT = RsData.GetSchemaTable()
Response.Write(RsDataDT.Rows.Count)
Really wonder what when wrong.
Please advice.
Thank You.