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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:20:50+00:00 2026-06-14T06:20:50+00:00

I am trying to update a record in Access through VB.NET. This is my

  • 0

I am trying to update a record in Access through VB.NET. This is my code thus far. The objective is to search a barcode, it returns the data associated with it and the user is able to change the data and save the updated data. I have everything except the update part. This is my save button with the update code. I hope I made this clear.

EDIT: Sorry. I forgot to tell you all my problem. It returns 0 rows affected, no error message.

 Private Sub btnEditProductSave_Click(sender As System.Object, e As System.EventArgs) Handles btnEditProductSave.Click
    'Creates Transaction and Connection Objects
    Dim Transaction As OleDb.OleDbTransaction = Nothing
    Dim connection As OleDb.OleDbConnection = Nothing

    Try

        'Assign the Connection 
        connection = New OleDb.OleDbConnection(My.Settings.POS_NEWConnectionString)
        'Opens the Connection and begins the Transaction
        connection.Open()
        Transaction = connection.BeginTransaction

        Dim barcode As String = txtEditProductBarcode.Text
        Dim name As String = txtEditProductName.Text
        Dim supplier As String = cbEditProductSupplier.SelectedValue
        Dim sell As Decimal = Val(txtEditProductSellPrice.Text)
        Dim quantity As Integer = numQuantity.Value
        Dim discount As Decimal = Val(txtEditProductDiscount.Text)
        Dim department As Integer = Val(txtEditProductDepartment.Text)

        Dim SQL As String = "UPDATE PRODUCT SET ProductName = @productName, SupplierId = @supplier, SellPrice = @sellPrice, Quantity = @quantity, DiscountPrice = @discount, DepartmentNumber = @dept WHERE ProductBarcode = @barcode"

        'Creates the Command for the Transaction
        Dim CT1 As New OleDb.OleDbCommand

        'Assigns a connection and transaction to a new command object
        CT1.Connection = connection
        CT1.Transaction = Transaction


        CT1.Parameters.AddWithValue("@barcode", barcode)
        CT1.Parameters.AddWithValue("@productName", name)
        CT1.Parameters.AddWithValue("@supplier", supplier)
        CT1.Parameters.AddWithValue("@sellPrice", sell)
        CT1.Parameters.AddWithValue("@quantity", quantity)
        CT1.Parameters.AddWithValue("@discount", discount)
        CT1.Parameters.AddWithValue("@dept", department)

        CT1.CommandText = SQL

        Dim number As Integer = CT1.ExecuteNonQuery

        MsgBox(number & " of row were affected")

        CT1.Dispose()

    Catch ex As System.Exception
        System.Windows.Forms.MessageBox.Show(ex.Message)
    End Try
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-14T06:20:52+00:00Added an answer on June 14, 2026 at 6:20 am

    Parameters in OleDb are in index order, not name.

    Try it this way (barcode parameter last):

        CT1.Parameters.AddWithValue("@productName", name)
        CT1.Parameters.AddWithValue("@supplier", supplier)
        CT1.Parameters.AddWithValue("@sellPrice", sell)
        CT1.Parameters.AddWithValue("@quantity", quantity)
        CT1.Parameters.AddWithValue("@discount", discount)
        CT1.Parameters.AddWithValue("@dept", department)
        CT1.Parameters.AddWithValue("@barcode", barcode)
    

    You also have a BeginTransaction but no commit.

    It should look something like this:

    Dim tx As OleDb.OleDbTransaction = connection.BeginTransaction
    
    // blah - blah - blah
    
    tx.Commit()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to update a record from an Ms-Access table with VB.NET and ASP.NET.
I'm trying to update a record with JQuery/JSON but I'm seeing this error: An
I'm getting this error when I'm trying to update a record: ERROR [HY000] [Microsoft][ODBC
I'm trying to update the records in an Access database where the column Group
I am trying to update an existing record in a database using CoreData, but
I'm trying to update a single record in a table, but when I run
I am trying to get cakePHP to update a record in the database as
I am trying to update records with a image button. here is my code:
I am trying update text views while this loop is processing. Here is my
Im trying to update a table with the following code. If I change WHERE

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.