Solved

Visual Studio Visual Basic 2012, Automatically update a record when moving to next record without need for save button

Posted on 2014-09-22
2
491 Views
Last Modified: 2014-09-24
Trying to see if I can teach an old dog(me) new tricks. After years of using Access to create databases, I am trying to use Visual Studio 2012 Visual Basic to re-create some of the applications I have created. Right now my learning curve is more of a straight line than a curve. I am used to Microsoft Access handling all record update functions for me. I used the before update event for data validation. Then, if no errors were found, Access would write the updated data to the table. Not so with VB 2012. How do I get VB 2012 to error check a record before the update is written and then, if no errors are found, to write the changes (and/or add a new record) when moving to a new record. I have purchased a couple of books on VB 2012 and I cannot find the answer in any of them. I can't find it online. As a side issue, is there a book/tutorial that anyone could recommend that deals pretty much exclusively with handling databases? I would like to find one that takes me, step by step, thru the creation of a small vb project that updates data located in a SQL server.
0
Comment
Question by:rodneygray
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 40338702
There are quite a few tutorials online and following is just an example

http://www.homeandlearn.co.uk/NET/nets12p1.html

VB has this concept of disconnected database access where it downloads records from DB, allows you to work on it locally and then upload changes back to the DB if you want.

If you want to update records whenever current record changes then you can call the tableadapter.update method in your button clicks for all the next, previous buttons.
0
 
LVL 1

Author Comment

by:rodneygray
ID: 40340269
Found the solution on http://www.codeproject.com/Articles/12846/Auto-Saving-DataGridView-Rows-to-a-SQL-Server-Data
Had to add two subroutines and one class variable. Might need to add me.Validate(), have not tested yet.


Public Class SizeForm
    Dim UpdatePending As Boolean = False

   
Private Sub SizeBindingSource_ListChanged(sender As Object, e As System.ComponentModel.ListChangedEventArgs) Handles SizeBindingSource.ListChanged
        If Me.SupplyRoomDataSet.HasChanges Then
            Me.UpdatePending = True
        End If
    End Sub


Private Sub SizeDataGridView_RowValidated(sender As Object, e As DataGridViewCellEventArgs) Handles SizeDataGridView.RowValidated
        If UpdatePending Then
            Me.SizeTableAdapter.Update(Me.SupplyRoomDataSet)
            Me.UpdatePending = False
        End If
    End Sub
End Class
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question