default.aspx

来自「Code for VB.NET教程源码 很好的源码」· ASPX 代码 · 共 36 行

ASPX
36
字号
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<Script language="VB" runat="server">

  Public Sub Page_Load(sender As Object, e As EventArgs)
    Dim connection As SqlConnection
    Dim command As SqlCommand
    Dim reader As SqlDataReader
    Dim sqlSelect As String
    Dim dsn As String
    
    ' Name dsn and sql select
    dsn=ConfigurationSettings.AppSettings("DsnPubs")
    sqlSelect="Select * From stores"

    ' Connect to the database
    connection = New SqlConnection(dsn)
    command = New SqlCommand(sqlSelect, connection)

    ' Open the connection
    connection.Open()

    ' Create the reader
    reader = command.ExecuteReader()

    ' Populate the datagrid
    datagrid1.DataSource = reader
    datagrid1.DataBind()

    ' Close the connection
    connection.Close()
  End Sub

</Script>
<asp:datagrid id="datagrid1" runat="server" />

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?