本文介绍了从sqlreader读取值后,页面未重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    Dim reader As SqlDataReader
    Dim id As String = Me.loginid.Text
    Dim pass As String = Me.password.Text
    Dim st As String = ConfigurationManager.ConnectionStrings("contructionConnectionStringlap").ToString
    Dim con As New Data.SqlClient.SqlConnection(st)

    Dim q As String = "select *  from login where login_id = '" & id & "' and password = '" & pass & "' "
    Dim com As New Data.SqlClient.SqlCommand(q, con)
    con.Open()
    reader = com.ExecuteReader()

    If reader.HasRows Then
        reader.Read()
                 Dim role As String = (reader("role")).ToString()

        If role = "Admin" Then
            Response.Redirect("welcomeemployee.aspx")
        End If


    Else
        If MsgBox("Incorrect Password Or UserID", MsgBoxStyle.RetryCancel, "Warning") = MsgBoxResult.Cancel Then
            password.Text = ""
            loginid.Text = ""
        End If
    End If


        reader.Close()
        con.Close()
End Sub

推荐答案



If MsgBox("Incorrect Password Or UserID", MsgBoxStyle.RetryCancel, "Warning") = MsgBoxResult.Cancel Then
    password.Text = ""
    loginid.Text = ""
End If


这篇关于从sqlreader读取值后,页面未重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 15:44