Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click '// define a connection to the database Dim cn As New OleDbConnection(ConfigurationManager.ConnectionStrings("WhatEverNameYouWant").ConnectionString) '// define the sql statement to execute Dim cmd As New OleDbCommand("SELECT * FROM [Contacts]", cn) Try '// open the connection cn.Open() '// execute the sql statement Using reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection) While reader.Read() '// this loops through all of the returned records End While End Using Catch ex As Exception Response.Write(ex.Message) Finally If cn.State <> ConnectionState.Closed Then cn.Close() End If End Try End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.