1 Replies - 1192 Views - Last Post: 05 September 2011 - 12:00 PM Rate Topic: -----

#1 Richy15  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 25-July 11

[Question] How to save data in DB?

Posted 05 September 2011 - 08:28 AM

Hello,

I have a db created in MS Access 2007. I have the table like this, for example:

Customers
------------------------------------
FirstName | LastName | Email |
------------------------------------
John | Einstein | jein@mail.com|
------------------------------------

I am trying to add/delete/modify/etc data in it using an application in VB.NET that I am creating. The problem is that I can't (or I don't know) save the data that I want to add/delete/etc. I mention that I don't load it programatically. I loaded with a DataGridView, DataSet, BindingSource and TableAdapter. How can I update/save the data in the db permanently?

Here is some code where I am trying to add data (this code is just for test):

Private sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.CustomersTableAdapter.Fill(Me.Db_testDataSet.Customers)
        Me.Db_testDataSet.AcceptChanges()
End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Db_testDataSet.Customers.AddCustomersRow(TextBox1.Text, TextBox3.Text, TextBox2.Text, ComboBox1.Text)
        Try
            Me.CustomersTableAdapter.Update(Me.Db_testDataSet.Customers)
            Label3.Text = "Saved successfully!"
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error!")
     End Try
End Sub




Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: [Question] How to save data in DB?

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5529
  • View blog
  • Posts: 11,843
  • Joined: 02-June 10

Re: [Question] How to save data in DB?

Posted 05 September 2011 - 12:00 PM

We have an entire tutorials section just for databases. Have you checked it out and done some of them?

See FAQ #24 for database questions


FAQ (Frequently Asked Questions - Updated Aug 2011

Spoiler

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1