登录后default.aspx页面无法打开. [英] after login default.aspx page is not opening.

查看:302
本文介绍了登录后default.aspx页面无法打开.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Imports System.Data.SqlClient.SqlConnection
Imports System.Data.SqlClient

Public Class login11
    Inherits System.Web.UI.Page
    Public Function Validate_Login(ByVal Username As String, ByVal Password As String) As Integer

        Dim con As SqlConnection = New SqlConnection("Data Source=KARANDE\sqlexpress;Initial Catalog=nitink;Integrated Security=True")
        Dim cmdselect As SqlCommand = New SqlCommand()
        cmdselect.CommandType = CommandType.StoredProcedure
        cmdselect.CommandText = "[dbo].[Log_prcLog]"

        cmdselect.Parameters.AddWithValue("@Username", Username)
        cmdselect.Parameters.AddWithValue("@UPassword", Password)
        cmdselect.Parameters.AddWithValue("@OutRes", SqlDbType.Int)



        '   cmdselect.Parameters.Add("@Username", SqlDbType.VarChar, 50).Value = Username
        ' cmdselect.Parameters.Add("@UPassword", SqlDbType.VarChar, 50).Value = Password
        'cmdselect.Parameters.Add("@OutRes", SqlDbType.Int, 4)
        cmdselect.Parameters("@OutRes").Direction = ParameterDirection.Output
        cmdselect.Connection = con
        Dim Results As Integer = 0
        Try
            con.Open()
            cmdselect.ExecuteNonQuery()
            Results = CType(cmdselect.Parameters("@OutRes").Value, Integer)
        Catch ex As SqlException
            lblMessage.Text = ex.Message
        Finally
            cmdselect.Dispose()
            If Not con Is Nothing Then
                con.Close()
            End If
        End Try
        Return Results
    End Function

    Protected Sub btnlogin_Click(sender As Object, e As EventArgs)
        Dim Results As Integer = 0
        If txtUsername.Text <> String.Empty AndAlso txtPassword.Text <> String.Empty Then
            Results = Validate_Login(txtUsername.Text.Trim(), txtPassword.Text.Trim())


            If Results = 1 Then
                lblMessage.Text = "Login is Good, Send the User to another page or enable controls"
            Else
                lblMessage.Text = "Invalid Login"
                lblMessage.ForeColor = System.Drawing.Color.Red

            End If
        Else
            lblMessage.Text = "Please make sure that the username and the password is Correct"
        End If

    End Sub

End Class

推荐答案

If Results = 1 Then
lblMessage.Text = "Login is Good, Send the User to another page or enable controls"
Else
lblMessage.Text = "Invalid Login"
lblMessage.ForeColor = System.Drawing.Color.Red

End If
Else
lblMessage.Text = "Please make sure that the username and the password is Correct"
End If




您只在标签中显示消息.重定向代码在哪里(default.aspx),并检查Results变量上的值.




Your are showing only message in the label. Where is the redirection code.(default.aspx ) and check what value you are getting on Results variable.


这篇关于登录后default.aspx页面无法打开.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆