Updating database from datagridview in vb net

Data will be saved in the database table and also displayed in the Data Grid View on the form. Suppose we selected a row which has the User Name monu and the user ID 38.Now click on the Delete Button to delete the row from the Data Grid View and database: Now select a row from the Data Grid View.The best way normally to start learning how to make such systems is to learn basic CRUD with database. We assume that you can create a ms access database. You then specify the path to the database in the connection string in our code. Ole Db Public Class Form1 'GLOBAL DECLARATIONS Dim con String As String = "Provider=Microsoft. OLEDB.4.0; Data Source=C:/Users/Sedan/Documents/Data Bases/people DB.mdb;" Dim con As Ole Db Connection = New Ole Db Connection(con String) Dim cmd As Ole Db Command Dim adapter As Ole Db Data Adapter Dim dt As Data Table = New Data Table() Private Sub Form1_Load(sender As Object, e As Event Args) Handles My Base.

updating database from datagridview in vb net-15updating database from datagridview in vb net-84updating database from datagridview in vb net-54updating database from datagridview in vb net-28

Now run the application Press CTRL F5 to run the application: Now enter the User Name, Password, Country and Email and click on the save Button: Now click on the save Button. Close() Retrieve() Catch ex As Exception Msg Box(ex. Close() End Try End Sub 'POPULATE LISTVIEW Private Sub Populate(name As String, pos As String, team As String) 'ROW ARRAY Dim row As String() = New String() Dim item As List View Item = New List View Item(row) 'ADD TO ROWS COLLECTION List View1. Add(item) End Sub 'RETRIEVE FROM DB Private Sub Retrieve() List View1. Clear() 'SQL STM Dim sql As String = "SELECT * FROM people TB " cmd = New Ole Db Command(sql, con) 'OPEN CON, RETRIEVE, FILL LISTVIEW Try con. Execute Non Query() 0 Then Msg Box("Successfully Inserted") Cleartext Boxes() End If con. Basically I have tried to make the normal Add (Insert), Edit, Update and delete functions in ASP.Net Grid View simple and also combining the powers of ASP.