sentDT is a DataTable passed in to a function. It has data in it. The code compiles, but when I run it I get this error:Code:Dim dt As DataTable Dim i As Int32 For i = 0 To sentDT.Columns.Count - 1 dt.Columns.Add(sentDT.Columns(i).Caption, sentDT.Columns(i).DataType) Next
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
The error occurs on the dt.columns.add line.
What I am trying to do here is create a copy of sentDT columns, without having to write it all out by hand, since there are a good number of columns in this table.


Reply With Quote


Bookmarks