MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.
Imports System.Data Imports System.Data.OleDb Imports System.Configuration Public Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub 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 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.