Asp.Net Programming Asp.Net > Code Snippets Code Examples Executing Transact-SQL SELECT statement using SQLCommand Executing Transact-SQL SELECT statement using SQLCommand <%@ Page Language="VB" Debug="true" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SQLClient" %> <script language="VB" runat="server"> Sub Page_Load(Source as Object, E as EventArgs) Dim objConn As New SQLConnection("server=LOCALHOST;User id=SA;password=;database=Northwind") Dim objCommand As New SqlCommand("Select categoryName from Categories", objConn) objCommand.Connection.Open() Dim objReader As SqlDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection) While objReader.Read() response.Write(objReader.GetString(1) & "<br/>") End While objReader.Close() objConn.Close() end sub </script>