I have a function in a VB.Net script file, but it produces the error ‘CopyToDataTable’ is not a member of ‘system.array’. Any ideas?
Public Function CollectionFromTable(tableName As String, sql As String, sortOrder As String) As DataTable
Dim foundRows() As DataRow
foundRows = ds.Tables(tableName).Select(sql, sortOrder)
Return foundRows.CopyToDataTable
End Function
Note: I have the following imports at the top but still get the error.
Imports System
Imports System.Data
Imports System.Windows.Forms
Imports System.Math
Imports Microsoft.VisualBasic
Imports System.Collections.Generic
Imports System.Data.DataRow
Imports System.Linq
Imports System.Drawing
Imports System.Xml
Imports System.Collections
It’s an extension method in the
DataTableExtensionsclass. You need to have a reference to theSystem.Data.DataSetExtensions.dll. (You’ve already got an import for the right namespace.)