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 8878391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:42:03+00:00 2026-06-14T19:42:03+00:00

I get this error Visual Basic 9.0 does not support this kind of lambda

  • 0

I get this error “Visual Basic 9.0 does not support this kind of lambda expression” here ” ExecuteWithinTransaction(Sub(con, trans) InsertA(“Al”, con, trans))” when i hover over the Sub

I am new to lambda expressions. Any help appreciated. I am using VS 2010 and .NET 3.5.

Sub Main() 
    ExecuteWithinTransaction(Sub(con, trans) InsertA("Al", con, trans))
    ExecuteWithinTransaction(Sub(con, trans) InsertB("Bert", con, trans))

    ExecuteWithinTransaction(Sub(con, trans)
                                 InsertA("Albert", con, trans)
                                 InsertB("Einstein", con, trans)
                             End Sub)
End Sub

''' <summary>
''' Executes an action within a transaction. handles connection and transaction management
''' </summary>
''' <param name="action">The action to be executed</param>
Sub ExecuteWithinTransaction(ByVal action As Action(Of SqlConnection, SqlTransaction))
    Dim connection As SqlConnection = New SqlConnection("CONNECTIONSTRING")

    connection.Open()
    Try
        Dim transaction = connection.BeginTransaction()

        Try
            action(connection, transaction)
            transaction.Commit()
        Catch ex As Exception
            transaction.Rollback()
            Throw 'rethrow exception preserving original stacktrace
        End Try
    Finally
        connection.Close()
    End Try 
End Sub

Sub InsertA(ByVal name As String, ByVal connection As SqlConnection, ByVal transaction As SqlTransaction)
    Dim cmd As SqlCommand = New SqlCommand("INSERT INTO XXX (Name) VALUES (@NAME)", connection, transaction)

    cmd.Parameters.AddWithValue("@Name", name)

    cmd.ExecuteNonQuery()
End Sub

Sub InsertB(ByVal name As String, ByVal connection As SqlConnection, ByVal transaction As SqlTransaction)
    Dim cmd As SqlCommand = New SqlCommand("INSERT INTO YYY (Name) VALUES (@NAME)", connection, transaction)

    cmd.Parameters.AddWithValue("@Name", name)

    cmd.ExecuteNonQuery()
End Sub
  • 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-06-14T19:42:04+00:00Added an answer on June 14, 2026 at 7:42 pm

    Statement lambdas (Subs) are supported in VB.NET 2012+.

    VB.NET 2010 only supports function lambdas (Functions).

    See Ric’s comments below for the answer.

    Workaround if changing FW version is not possible: Write little helper subs in the ordinary, non-lambda form, and then pass them as delegates to ExecuteWithinTransaction.

    So you would have

    private sub Lambda1 (con as SqlConnection, tran as SqlTransaction)
      InsertA("Al", con, tran)
    end sub
    
    private sub Lambda2 (con as SqlConnection, tran as SqlTransaction)
      InsertB("Bert", con, tran)
    end sub
    
    private sub Lambda3 (con as SqlConnection, tran as SqlTransaction)
      InsertA("Albert", con, tran)
      InsertB("Einstein", con, tran)
    end sub
    

    And then

    ExecuteWithinTransaction (AddressOf Lambda1)
    ExecuteWithinTransaction (AddressOf Lambda2)
    ExecuteWithinTransaction (AddressOf Lambda3)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried this code on Visual C++ 2008 express edition, but it does not
I compile in Visual studio 2008 and get this error. I have researched linkage
I get this error while accessing a php script: W/System.err: Error reading from ./org/apache/harmony/awt/www/content/text/html.class
I get this error when i try to upload an image: OSError at /upload/
I get this error on my Ice Cream Sandwich (Android 4.0) device and emulator.
I get this error when I run the code below. I have normally used
I get this error when I use simplejson from django.utils in google app engine
I get this error in my app { error: { message: Missing client_id parameter.,
i get this error Cannot open database DataLayer.Context.MedicallexiconContext requested by the login. The login
I get this error TypeError at /debate/1/ get_context_data() takes exactly 2 arguments (1 given)

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.