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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:44:20+00:00 2026-05-24T10:44:20+00:00

I have a VB Solution with a dozen forms trying to implement invoice system.

  • 0

I have a VB Solution with a dozen forms trying to implement invoice system.

My main form (Say Form1) only has a design to create , Edit or Delete Customers.
My form 2 will be opened if Create button is clicked. In my form 2, I have textboxes where user can enter Customer details and click on SAVE. My doubt is here….

On clicking this SAVE button in Form 2, I want a INSERT command to happen on the MSAccess’s Database table called Customer (which I have already created… this table does not have any records as of now).

In my form 1, I added a MSAccess Database with a Connection String. In my Form1’s code I have code like this

Public Class Form1

      'Code specific to Form1's elements

End Class

Public Class Connection
    Private Shared connection As OleDb.OleDbConnection

    Public Shared ReadOnly Property Instance() As OleDb.OleDbConnection
        Get
            If connection Is Nothing Then
                connection = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Invoice.mdb")
            End If
            Return connection
        End Get
    End Property
End Class

In my form 2, I have some code like this … when SAVE is clicked

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim myConnection As OleDb.OleDbConnection
        myConnection = Connection.Instance

    End Sub

I got this piece of code from this link [1]: vb.net – sharing mdb access connection among multiple forms

Now, I do not know what more code does this require to INSERT records from my text box into the Customer table’s fields. Can anyone help, please?

  • 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-24T10:44:22+00:00Added an answer on May 24, 2026 at 10:44 am

    Once you have the connection, you can do a normal insert into the Access table. You didn’t specify if you were doing the insert by a string of SQL, or via a Stored Procedure. For simplicity my example uses the former, however I strongly recommend either a parameterized query (if you’re doing a string of SQL) or a stored procedure to prevent SQL Injection attacks.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
        Try
    
            Dim myConnection As OleDb.OleDbConnection = Connection.Instance
    
            myConnection.Open()
    
            Dim sqlString As String = "" ' Put your insert SQL here
            Dim myCommand As New OleDbCommand(sqlString, myConnection)
    
            Dim rows As Integer = myCommand.ExecuteNonQuery
        Catch ex As Exception
            // Handle any errors here
        Finally
            myConnection.Close()
        End Try
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a solution with several projects, where the startup project has a post-build
I have a solution in Visual Studio 2005(professional Edition) which in turn has 8
In my main application Form I have a number of menu and toolbar button
I have a model that already has a couple dozen of columns that will
I've got a situation where I have a main form that pops up an
Our shop has developed a few WEB/SMS/DB solution for a dozen client installations. The
Currently I have solution A that contains a domain layer base and solution B
I have a solution with several projects. One of them is a setup project.
I have a solution with many projects. One project contain few custom components. One
I have a solution consisting of five projects, each of which compile to separate

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.