一個簡單的使用者登陸程式……

來源:互聯網
上載者:User
Content-Type: Text/Plain; charset="gb2312"
Content-Transfer-Encoding: 8bit

以下程式是用來驗證使用者登入的共有兩個按鈕,一個是用來提交的,一個是用來重填的,頁面部分就很簡單了,兩個文字框,兩個按鈕,這裡頁面的代碼就不寫了:)

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If TextBox3.Text = "" Or TextBox4.Text = "" Then
            Label35.Text = "請確認您的輸入!"
            Return
        End If
        Dim sql As String = "select * from pwd where stu_id=@stu_id and pwd=@pwd"
        Dim comm As SqlCommand = New SqlCommand(sql, conn)
        comm.Parameters.Add(New SqlParameter("@stu_id", SqlDbType.Int, 4))
       comm.Parameters("@stu_id").Value = TextBox3.Text
        comm.Parameters.Add(New SqlParameter("@pwd", SqlDbType.Char, 16))
        comm.Parameters("@pwd").Value = TextBox4.Text
        Dim dr As SqlDataReader
        conn.Open()
        dr = comm.ExecuteReader
        If dr.Read Then
            Session("stu_id") = TextBox3.Text
            dr.Close()
            comm.Cancel()
            Dim sql_3 As String = "update stu_base set point=point+1 where stu_id=@stu_id"
            comm = New SqlCommand(sql_3, conn)
            comm.Parameters.Add(New SqlParameter("@stu_id", SqlDbType.Int, 4))
            comm.Parameters("@stu_id").Value = Session("stu_id")
           comm.ExecuteNonQuery()
            comm.Cancel()
            Response.Redirect("detail.aspx?stu_id='" & Session("stu_id") & "'")
        Else
            Label35.Text = "您還沒有註冊或帳號密碼錯誤"
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
    End Sub 




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.