Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7094161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:31:44+00:00 2026-05-28T08:31:44+00:00

I have got this error No default member found for type ‘VB$AnonymousDelegate_0(Of SqlDataReader,String,Object)’. My

  • 0

I have got this error
No default member found for type 'VB$AnonymousDelegate_0(Of SqlDataReader,String,Object)'.

My Code is below

dsBranch.Tables.Add(GetDataTableFromSQLReader(dr, "")) – Calling

Private Function GetDataTableFromSQLDataReader(ByVal dr As SqlDataReader, ByVal TableName As String)
    Dim dt As New DataTable(TableName)
    dt.Load(dr)
    Return dt
End Function
Dim GetDataTableFromSQLReader = Function(dr As SqlDataReader, TableName As String) GetDataTableFromSQLDataReader(dr, TableName)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:31:45+00:00Added an answer on May 28, 2026 at 8:31 am
    Imports System.Data
    Imports System.Data.SqlClient
    
    Public Class NoDefaultMemberFoundError
    
        ' Added "As DataTable"
        Private Function GetDataTableFromSQLDataReader(ByVal dr As SqlDataReader, _
                                                       ByVal TableName As String) As DataTable
            Dim dt As New DataTable(TableName)
            dt.Load(dr)
            Return dt
        End Function
    
        ' This is how it has to be declared
        Dim GetDataTableFromSQLReader As Func(Of SqlDataReader, String, DataTable) = _
                           Function(dr, TableName) GetDataTableFromSQLDataReader(dr, TableName)
    
        Sub Test()
            Dim dsBranch As DataSet = Nothing
            Dim dr As SqlDataReader = Nothing
    
            dsBranch.Tables.Add(GetDataTableFromSQLReader(dr, ""))
        End Sub
    End Class
    

    You should set the Option Strict to On. It would help you to declare the correct types. For instance, your Function had no return type declared. This was probably the main source of the error.

    Your Lambda assignment was also not correct. Lambda expressions always have to be assigned to a concrete type. This enables the compiler to infer their exact signature.


    EDIT (explanation of delegates and lambda expressions):

    With

    Dim GetDataTableFromSQLReader As Func(Of SqlDataReader, String, DataTable)
    

    you define a variable, which can hold a function, or more precisely its address, in a specialized class called a ‘delegate’. In terms of .NET this variable is a delegate which refers to a method (unless it is Nothing). According to the declaration above, this function must accept one parameter of type SqlDataReader and one of type String. The return value must be of type DataTable.

    You can assign any function, which has this requested signature to the variable:

    GetDataTableFromSQLReader = AddressOf GetDataTableFromSQLDataReader
    

    is a valid assignment. (I could have simplified the example in my original answer this way.) Now you can use the variable as if it was a function:

    Dim DataTable dt = GetDataTableFromSQLReader(dr, "")
    

    In reality this calls the function that was assigned to it, namely GetDataTableFromSQLDataReader. This makes sense, if we want to get the data tables in different ways. We could assign another function, say GetDataTableInADifferentWay to our variable. The call GetDataTableFromSQLReader(dr, "") would then call this other function without the need of having an If-Then-Else-statement when we call it.

    Now, to the lambda expressions with a detour over delegates. Let us take an example that is more suitable. We want to print a table with function values:

    Public Sub PrintFunction()
        For Dim x As Double = 1 To 10
            Console.WriteLine("x = {0}, f(x) = {1}", x, x*x)
        Next
    End Sub
    

    As you can see, we print the squares of 1 to 10. However, what about printing other functions? We would have to change our PrintFunction each time we need to print another function. Here delegates come into the game. Let us change the declaration to

    Public Sub PrintFunction(Func(Of Double, Double) f)
        For Dim x As Double = 1 To 10
            Console.WriteLine("x = {0}, f(x) = {1}", x, f(x))
        Next
    End Sub
    

    Now let us declare a square function and a reciprocal function

    Public Function Square(x As Double) As Double
        Return x*x
    End Function
    
    Public Function Reciprocal(x As Double) As Double
        Return 1 / x
    End Function
    

    Now we can print two different value tables with

    PrintFunction(AddressOf Square)
    PrintFunction(AddressOf Reciprocal)
    

    We have not used lambda expressions yet. They are simply a very concise way of declaring delegates (or functions, if you prefer) on the fly. Instead of declaring a square and a reciprocal function, we can print the tables like this:

    PrintFunction(Function(x) x*x)
    PrintFunction(Function(x) 1 / x)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got this error when using Enterprise Library 3.1 May 2007 version. We
I have this but I got an error: -- test if a list contains
I have got this code: XDocument xdoc = XDocument.Load(URI); XElement root = xdoc.Element(forecast); //get
I have got this code and I am trying to understand the convention followed,
I have got some javascript code and I'd like to convert this to C#.
I have got a piece of code, that should countdown some number (in this
while compiling the following code i have got error @Override public void routeCustomerRequest (int
While configuring MJAndriod I have got an error as follows: Project has no default.properties
I have got an XML document which looks something like this. <Root> <Info>....</Info> <Info>....</Info>
So I've got this UpdatePanel. Inside it I have a nifty little jQuery scroll

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.