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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:22:06+00:00 2026-06-15T04:22:06+00:00

I am trying to insert into Microsoft Access database from VB.net. I can read

  • 0

I am trying to insert into Microsoft Access database from VB.net.
I can read from the Data Base(can see in Grid View) but cannot insert into Database.I don’t know where the problem is.
This is what i am doing:

Imports System.Data
Imports System.Data.OleDb

Public Class Form1
Public ctr As Integer
Dim bm As BindingManagerBase
Dim dr As DataRow, dt As DataTable
Dim flag As Integer, tid As Integer, tname As String
Dim totalrow As Integer, currentrow As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'TODO: This line of code loads data into the 'ShowroomDataSet.customer' table. You can move, or remove it, as needed.
    bm = Me.BindingContext(ShowroomDataSet, "customer")
    bm.Position = 0
    Me.CustomerTableAdapter.Fill(Me.ShowroomDataSet.customer)

 End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim x As Integer
    Dim y As String
    bm.Position = bm.Count - 1
    x = ShowroomDataSet.customer(bm.Position).cid
    y = ShowroomDataSet.customer(bm.Position).cname
    TextBox1.Text = x
    TextBox2.Text = y

  End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    Close()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    'save
    'enable all buttons except save
    If flag = 1 Then
        dt = ShowroomDataSet.Tables("customer")
        dr = dt.NewRow()
        dr!cid = Val(TextBox1.Text)
        dr!cname = TextBox2.Text
        dt.Rows.Add(dr)

    End If
    If flag = 2 Then
        dr.Delete()
    End If
    If flag = 3 Then
        dt = ShowroomDataSet.Tables("customer")
        dr = dt.Rows.Find(tid)
        dr.BeginEdit()
        dr!cid = Val(TextBox1.Text)
        dr!name = TextBox2.Text
        dr.EndEdit()
    End If
    'Me.CustomerTableAdapter.Update(Me.ShowroomDataSet.customer)
    'Me.CustomerTableAdapter.Fill(Me.ShowroomDataSet.customer)
    flag = 0
    Button1.Enabled = True
    Button2.Enabled = False
    Button3.Enabled = True
    Button4.Enabled = True

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    'add
    'disable all buttons except save
    Dim len As Integer
    TextBox1.Text = " "
    TextBox2.Text = " "
    flag = 1
    TextBox1.Focus()
    Button1.Enabled = False
    Button2.Enabled = True
    Button3.Enabled = False
    Button4.Enabled = False
    dt = ShowroomDataSet.Tables("customer")
    len = dt.Rows.Count - 1
    dr = dt.Rows(len)
  End Sub
  End Class

No errors or faults.
Please help.

  • 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-15T04:22:07+00:00Added an answer on June 15, 2026 at 4:22 am

    If you are just looking to insert data into an access database use the database table adapter insert method, followed by the fill method of the table adapter to fill the a table in the dataset. See following example

    me.tableadapter.insert(me.1stFieldTextbox.text, me.2ndFieldTextBox.Text….)
    me.tableadapter.fill(me.Dataset.Table)

    If you get an error, it could be because your data types do not match, you try to insert data into an auto increament field or one which has a calculated data type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to insert rows into a MySQL database from an Access database
I'm trying to insert data into my SQlite3 database (this works via the command
I am trying to INSERT some data in ms access database using jsp but
I'm trying to insert some data into a table from a csv document which
I am trying to insert into my database table using the database helper class.
hi am trying to insert values into SQL database using jdbc. Current code able
Trying to insert values with Unicode Chars into a MySQL-database using Delphi 2010 and
I am trying to query an Microsoft SQL 2005 database, process the data and
I get this error when trying to insert a date to my database from
I am getting this error when trying to insert data into a data table

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.