• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 415
  • Last Modified:

Run Action Query with VB.NET

I created an action query in MS Access and i would like to run that same query from VB.Net.  Since I need to run the code in multiple spots in my application, I would like another alternative than:

dim myStr as string = "Update ....."
dim myCmd as new command(mystr, myConnection)

mycmd.executenonquery()
0
rodmjay
Asked:
rodmjay
1 Solution
 
amyhxuCommented:
If you have several forms, you can put the method in a module, so it's global and can be accessed within the whole program.

Module Module1

    Public Sub UpdateDb(ByVal myConnection As OleDbConnection)
        dim myStr as string = "Update ....."
        dim myCmd as new command(mystr, myConnection)
        mycmd.executenonquery()
    End Sub

End Module

You can call UpdateDb(myConnection) from anywhere inside the application.

If you only have one form, then write it as a method, and call it from other subroutines.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now