⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 studentaddress.aspx.vb

📁 Programming Web and Desktop Applications in ADO .NET and ASP .NET
💻 VB
字号:
Public Class WebForm2
    Inherits System.Web.UI.Page
    Protected WithEvents Label1 As System.Web.UI.WebControls.Label
    Protected WithEvents conConnection As System.Data.OleDb.OleDbConnection
    Protected WithEvents cmdCommand As System.Data.OleDb.OleDbCommand
    Protected WithEvents lblAddress As System.Web.UI.WebControls.Label

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.conConnection = New System.Data.OleDb.OleDbConnection()
        Me.cmdCommand = New System.Data.OleDb.OleDbCommand()
        '
        'conConnection
        '
        Me.conConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\Inetpub" & _
        "\wwwroot\Chapter15\Course.mdb;Mode=Share Deny None;Extended Properties="""";Jet OL" & _
        "EDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password=""""" & _
        ";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Part" & _
        "ial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Passw" & _
        "ord="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;J" & _
        "et OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Re" & _
        "pair=False;Jet OLEDB:SFP=False"
        '
        'cmdCommand
        '
        Me.cmdCommand.Connection = Me.conConnection

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here

        'Retrieve and Display Student抯 Address, if available, using ID 

        Dim rdrReader As OleDb.OleDbDataReader
        Dim strID As String = Request.QueryString("ID")

        cmdCommand.CommandText = "Select * From StudentAddress " + _
        "Where StudentID ='" + strID + "'"

        conConnection.Open()
        rdrReader = cmdCommand.ExecuteReader()

        If rdrReader.Read Then
            lblAddress.Text = rdrReader("StudentID") + "<br>" + _
            rdrReader("Street") + "<br>" + rdrReader("City") + _
            ", " + rdrReader("State") + " " + rdrReader("Zip")
        Else
            lblAddress.Text = strID + "<br>" + "Address NOT available"
        End If

        conConnection.Close()
        cmdCommand.Dispose()
        conConnection.Dispose()

    End Sub

End Class

⌨️ 快捷键说明

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