As is well known, the biggest advantage of ADO.NET relative to ADO is that the update modification of the data can be performed in the case of completely disconnecting the data source, and then transfer the data update situation back to
data source. This greatly reduces the occupation of excessive connections for database server resources. Here is an example I have seen in the "ADO.NET Practice Guide", more clear explanation
How to use ADO.NET. Imports system.data.sqlclientimports system.dataimports system.data.common
Public class form1 inherits system.windows.Forms.form
Private Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim conn As New SqlConnection ( "data source = localhost; initial catalog = StudentCourse;" & _ "User ID =; Password =; ") Dim ds As New DataSet Try conn.Open () 'opens conn Dim daAuthors As before forming SqlDataAdapter New SqlDataAdapter (" Select * From SC ", conn) Dim bldr As New SqlCommandBuilder (daAuthors) daAuthors.Fill (ds," SC ") Conn.close () 'After the DS is filled, the connection is turned off, followed by the DS.
DIM TBL AS New DataTable TBL = DS.TABLES ("SC")
Dim rowvals (3) as object rowvals (0) = "5" Rowvals (1) = "00003" Rowvals (2) = "0001" Rowvals (3) = 99 DIM INSERTEDROW AS DATAROW INSERTEDROW = TBL.ROWS.Add (Rowvals ) 'Add a line
TBL.ROWS (0) .delete () 'Delete a line
TBL.ROWS (1). SegineDit () TBL.ROWS (1) ("score") = 89 'Modify a line TBL.ROWS (1) .endedit ()
Conn.open () Daauthors.Update ("sc")) 'Open the result back the connection back to the data source, update conn.close () catch exception messagebox.show (ex. measure) End Try End Subend Class