zoukankan      html  css  js  c++  java
  • 最简单Login程序

    代码
     Protected Sub btnLogon_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles btnLogon.Click

            
    If Page.IsValid Then

                
    Dim SQL As String = "Select pwd ,username from sys_user where username=@uid "
                
    Dim myconnection As SqlConnection = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("connstring"))
                
    Dim mycommand As SqlCommand = New SqlCommand(SQL, myconnection)
                myconnection.Open()
                mycommand.Parameters.Add(
    "@uid", SqlDbType.Char).Value = Trim(txtUserName.Text)
                mycommand.Parameters.Add(
    "@pwd", SqlDbType.Char).Value = Trim(txtPwd.Text)
                
    Dim myreader As SqlDataReader = mycommand.ExecuteReader

                
    If myreader.Read Then
                   
                    
    Dim mdString As String = Trim(txtPwd.Text)

                    
    If mdString = Trim(myreader.GetValue(0)) Then
                   
                        myreader.Close()
                        myreader 
    = Nothing
                        myconnection.Close()
                        myconnection 
    = Nothing
                        Response.Redirect(
    "index.html")

                    
    Else
                        myreader.Close()
                        myreader 
    = Nothing
                        myconnection.Close()
                        myconnection 
    = Nothing
                        Response.Write(
    "<script language='javascript'>alert('对不起,用户或密码错误!!');</script>")
                    
    End If
                
    Else
                    Response.Write(
    "<script language='javascript'>alert('对不起,没有此用户');</script>")
                
    End If
            
    End If


        
    End Sub
  • 相关阅读:
    List<int>转化为逗号链接的字符串
    分页的总页数算法
    高性能SQLServer分页语句
    webconfig中的&符号问题解决
    检测SQLServer复制订阅进度
    jQuery自定义数组操作类(类似于List集合的增删改查)
    解决jquery绑定click事件出现点击一次执行两次问题
    IdentityServer4登陆中心
    AES加密解密通用版Object-C / C# / JAVA
    T-SQL 基本语法
  • 原文地址:https://www.cnblogs.com/callbin/p/1620450.html
Copyright © 2011-2022 走看看