ADO.NET Overview
Sample access using Data Reader:
' Setup connection
Dim myConnection AsNew OleDb.OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Program Files\Microsoft Visual " & _
"Studio.NET\Common7\Tools\Bin\nwind.Mdb")
' Setup command object, specifying SELECT
' and connection to use
Dim myCommand AsNew OleDb.OleDbCommand( _
"Select * from Customers", myConnection)
Dim myReader AsOleDb.OleDbDataReader
' Open connection
myConnection.Open()
' Execute and put results into reader
myReader = myCommand.ExecuteReader
' Read through all the records
Do UntilmyReader.Read = False
MessageBox.Show(myReader("CompanyName"))
Loop
' Close reader connection before continuing
myReader.Close()
myConnection.Close()
Sample access using Data Adapter:
' Setup connection
Dim myConnection AsNew OleDb.OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Program Files\Microsoft Visual " & _
"Studio.NET\Common7\Tools\Bin\nwind.Mdb")
' We're just specifying the SELECT here.
' If done visually using the Server Explorer,
' the INSERT/UPDATE/DELETE + Parameters
' collection would be auto-specified for us
Dim myDataAdapter AsNew OleDb.OleDbDataAdapter( _
"Select * from Customers", myConnection)
Dim myDataSet AsNew DataSet()
' Fill DataSet with table, call it 'Customers'
myDataAdapter.Fill(myDataSet, "Customers")
' Display first CompanyName field of first
' row in Customers table
MessageBox.Show(myDataSet.Tables("Customers").Rows(0)("CompanyName"))
' If we had specified INSERT/UPDATE/DELETE
' commands + Parameters collection, we could
' also now edit the data, then run somethinglike:
' myDataAdapter.Update(myDataSet)
Sample access using XML:
Dim myDataSet AsNew DataSet()
myDataSet.ReadXml("c:\books.xml")
' Books.xml is file bundled with VS.NET,
' typically located at:
' C:\Program Files\Microsoft.NET\FrameworkSDK
' ... \Samples\quickstart\howto\samples\xml
' ... \xmldocumentevent\vb\books.xml
' Counts the number of book nodes
MessageBox.Show(myDataSet.Tables("book").Rows.Count)
' Retrieves the last name of the first author
MessageBox.Show(myDataSet.Tables( _
"author").Rows(0)("last-name"))
' Updates the last name
myDataSet.Tables("author").Rows(0)( _
"last-name") = "Flandadenham"
' Rewrites the XML file
myDataSet.WriteXml("c:\books.xml")



Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.
Discover how to start developing for the Android platform with this extensive guide, which provides a reference to the Android platform as well as a look at developing your first Android application. You'll explore the top 10 features for developers as well as learn design and development tips that go beyond the phone and target tablet development as well.