1 Replies - 2557 Views - Last Post: 15 July 2010 - 06:25 PM Rate Topic: -----

#1 colinburriss  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 01-November 09

Visual Basic 2008 and Access 2007

Posted 13 July 2010 - 12:31 PM

My Visual Basic 2008 can insert a new row to a dataset, but the dataset does not insert new rows into the actual Access 2007 database. The database remains unchanged and there are no error messages. How can the dataset write the new row to the database?

VB2008 code:
    Private Sub btnNewUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewUser.Click
        Dim NewUser = Me.UsersTableAdapter.NewUserString(txtUsername.Text, txtPassword.Text)

        UsersTableAdapter.Fill(Me.dsUsers.Users)

        txtUsername.Clear()
        txtPassword.Clear()
        MsgBox("username and password accepted, now please log in")
    End Sub


SQL INSERT statement
INSERT INTO Users
                      (Username, [Password])
VALUES     (?, ?)


Is This A Good Question/Topic? 0
  • +

Replies To: Visual Basic 2008 and Access 2007

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 3872
  • View blog
  • Posts: 11,405
  • Joined: 18-April 07

Re: Visual Basic 2008 and Access 2007

Posted 15 July 2010 - 06:25 PM

Check out the Update() method of your data adapter. It can take a dataset (typically the one you created with Fill()) and updates it back to the database. I suggest you actually create a dataset, add a new row to it and then call the data adapter's update() method to update the database again.

Just to get you started...

DataAdapter.Update Method - MSDN

Enjoy! :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1