<%@ 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 conn As New SQLConnection("server=LOCALHOST;User id='sa';password='123';database=Northwind")
Dim cmd As New SqlCommand("Select categoryName from Categories", conn)
cmd.Connection.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
While reader.Read()
response.Write(reader.GetString(1) & "<br/>")
End While
reader.Close()
conn.Close()
end sub
</script>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<script language="VB" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
Dim conn As New SQLConnection("server=LOCALHOST;User id='sa';password='123';database=Northwind")
Dim cmd As New SqlCommand("Select categoryName from Categories", conn)
cmd.Connection.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
While reader.Read()
response.Write(reader.GetString(1) & "<br/>")
End While
reader.Close()
conn.Close()
end sub
</script>
0 Response to ASP.NET: Thực thi truy vấn SELECT sử dụng đối tượng SQLCommand
Post a Comment