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

📄 s_index.aspx.vb

📁 vb。net 2003数据库设计整套源代码
💻 VB
字号:
Imports System.Data
Imports System.Data.SqlClient

Public Class WebForm2
    Inherits System.Web.UI.Page
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button
    Protected WithEvents Label1 As System.Web.UI.WebControls.Label
    Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Button2 As System.Web.UI.WebControls.Button
    Protected WithEvents ddlist As System.Web.UI.WebControls.DropDownList
    Protected WithEvents MyDataGrid As System.Web.UI.WebControls.DataGrid

#Region " Web 窗体设计器生成的代码 "

    '该调用是 Web 窗体设计器所必需的。
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
        '不要使用代码编辑器修改它。
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '在此处放置初始化页的用户代码
        If Session("userid") = "" Then
            Response.Redirect("unlogin.aspx")
        End If
    End Sub

    Sub search1()
        Dim myConnection As SqlConnection
        Dim myCommand As SqlDataAdapter
        myConnection = New SqlConnection("user id=sa;password=;server=qianzh;" _
       & "database=library")
        Dim sqlstring As String
        sqlstring = " SELECT * FROM borrow where userid =" & Session("userid")

        myCommand = New SqlDataAdapter(sqlstring, myConnection)

        Dim ds As DataSet = New DataSet()
        myCommand.Fill(ds)
        ' Bind MyDataGrid to the DataSet. MyDataGrid is the 
        ' ID for the DataGrid control in the HTML section.
        MyDataGrid.DataSource = ds
        MyDataGrid.DataBind()
    End Sub

    Sub search2()
        Dim searchString As String
        If ddlist.SelectedItem.Text = "题名" Then
            searchString = "SELECT * FROM books where bookname='" & TextBox1.Text & "'"
        ElseIf ddlist.SelectedItem.Text = "出版单位" Then
            searchString = "SELECT * FROM books where press='" & TextBox1.Text & "'"
        ElseIf ddlist.SelectedItem.Text = "作者" Then
            searchString = "SELECT * FROM books where author='" & TextBox1.Text & "'"
        ElseIf ddlist.SelectedItem.Text = "出版年份" Then
            searchString = "SELECT * FROM books where year='" & TextBox1.Text & "'"
        End If
        Dim myConnection As SqlConnection
        Dim myCommand As SqlDataAdapter
        ' Create a connection to the "pubs" SQL database located on the 
        ' local computer.
        myConnection = New SqlConnection("user id=sa;password=;server=qianzh;" _
            & "database=library")
        ' Connect to the SQL database using a SQL SELECT query to get all 
        ' the data from the "Authors" table.
        myCommand = New SqlDataAdapter(searchString, myConnection)
        ' Create and fill a DataSet.
        Dim ds As DataSet = New DataSet()
        myCommand.Fill(ds)
        ' Bind MyDataGrid to the DataSet. MyDataGrid is the 
        ' ID for the DataGrid control in the HTML section.
        MyDataGrid.DataSource = ds
        MyDataGrid.DataBind()
    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        search1()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        search2()

    End Sub
End Class

⌨️ 快捷键说明

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