Imports System.Data.SqlClient Partial Public Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Create and open aconnection to Northwind database Dim conn As SqlConnection = New SqlConnection("Data Source=.;Initial Catalog=Northwind;Integrated Security=TRUE") 'Dim conn As SqlConnection = new SqlConnection("Data Source=ACER-2E68C49B20;AttachDbfilename=D:\My Documents\SQL Server\Northwind.mdf;Integrated Security=TRUE") conn.Open() 'Create a SQL statement to get rows from the Employees table Dim queryString As String = "SELECT CustomerID, CompanyName FROM dbo.Customers" 'Create the command object Dim com As SqlCommand = New SqlCommand(queryString, conn) 'Call the command's ExecuteReader method Dim dr As SqlDataReader = com.ExecuteReader() 'Loop through the datareader to output the employee names While (dr.Read()) 'dr.GetString(1); ListBox1.Items.Add(dr("CustomerID").ToString() + " " + dr("CompanyName").ToString()) End While 'Close the datareader & connection dr.Close() conn.Close() End Sub End Class