Search code examples
vb.netiisashx

Error BC30456: 'ElementAtOrDefault' is not a member of 'System.Data.EnumerableRowCollection(Of System.Data.DataRow)'


The compiler on the server throws the error "'ElementAtOrDefault' is not a member of 'System.Data.EnumerableRowCollection(Of System.Data.DataRow)'" at the line:
Dim dr As DataRow = clientDataTable(0)
in my .ashx file. It also threw this error when I previously tried
Dim strFirstName As String = clientDataTable(0)("FirstName").ToString()
Am I declaring the DataRow incorrectly, or is there something else I'm missing?


Solution

  • Try using

    clientDataTable.Rows(0)
    

    Rather than just using (clientDataTable(0)) this will make sure you actually get rows back.