📄 webform1.aspx.vb
字号:
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents user_id As System.Web.UI.WebControls.TextBox
Protected WithEvents password As System.Web.UI.WebControls.TextBox
Protected WithEvents Radio1 As System.Web.UI.WebControls.RadioButton
Protected WithEvents login As System.Web.UI.WebControls.Button
Protected WithEvents Radio2 As System.Web.UI.WebControls.RadioButton
Protected WithEvents Message As System.Web.UI.HtmlControls.HtmlGenericControl
#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
'在此处放置初始化页的用户代码
End Sub
Public Sub check_log1()
' 定义数据库连接
Dim myConnection As SqlConnection
myConnection = New SqlConnection("user id=sa;password=;server=qianzh;" _
& "database=library")
Dim searchCmd As String
searchCmd = "select * from reader where userid = '" & user_id.Text & "' and password='" & password.Text & "'"
Dim myCommand As SqlCommand = New SqlCommand(searchCmd, _
myConnection)
myCommand.Connection.Open()
Dim myReader As SqlDataReader = myCommand.ExecuteReader()
If myReader.Read() Then
Session("userid") = user_id.Text
Response.Redirect("s_index.aspx")
ElseIf Not myReader.Read() Then
Message.InnerHtml = "你的输入有误"
Message.Style("color") = "red"
End If
myCommand.Connection.Close()
End Sub
Public Sub check_log2()
' 定义数据库连接
Dim myConnection As SqlConnection
myConnection = New SqlConnection("user id=sa;password=;server=qianzh;" _
& "database=library")
Dim searchCmd As String
searchCmd = "select * from manager where mgrid = '" & user_id.Text & "' and password='" & password.Text & "'"
Dim myCommand As SqlCommand = New SqlCommand(searchCmd, _
myConnection)
myCommand.Connection.Open()
Dim myReader As SqlDataReader = myCommand.ExecuteReader()
If myReader.Read() Then
Response.Redirect("t_index.aspx")
ElseIf Not myReader.Read() Then
Message.InnerHtml = "你的输入有误"
Message.Style("color") = "red"
End If
myCommand.Connection.Close()
End Sub
Private Sub login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles login.Click
If Radio1.Checked Then
check_log1()
ElseIf Radio2.Checked Then
check_log2()
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -