从sqlreader读取值后,页面未重定向 [英] Page is not redirecting after reading the value from a sqlreader

查看:92
本文介绍了从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

推荐答案

真可惜.也许您应该检查一下您输入的数据.显然,您没有从查询中得到期望的结果.

您在此处提供的信息不能完全表明您的问题所在.
That''s a shame. Perhaps you should check you input data. Obviously you are not getting what you expect returned from your query.

The information you have given here doesn''t provide any indication whatsoever as to what your issue is.


老兄,检查一下您在role变量中获得的值.我认为这是普通拼写错误的典型案例.
dude, check the value you are getting in the role variable. I think this is a classic case of a ordinary typo.


您确实意识到,除非您建立自己的权利,否则您无法在网页中使用此功能?

You do realize you cannot use this within a webpage unless you build your own right?

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


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

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