Asp Codes
ActiveX
ADO
Array
Code Snippets
Components
Data Access
Date Time
Files
Graphics
HTML Formatting
Mathematics
Miscellaneous
Sessions
SQL
Strings
Techniques
XML
Asp.Net > Code Snippets sample source codes
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>
Privacy Policy
|
Link to Us
|
Links