Asp.net 如何获取通过querystring参数传递的用户名的userrole

Asp.net 如何获取通过querystring参数传递的用户名的userrole,asp.net,Asp.net,我需要识别通过querystring传递的用户名的用户角色。我正在使用SQL数据库并在aspnet中工作。有人能建议如何实现吗?你可以试试 String sql = "SELECT * FROM table_name WHERE [UserId] = 'REQUESTED_USERNAME' && [Password] = 'REQUESTED_PASSWORD'"; string strCon = System.Web

我需要识别通过querystring传递的用户名的用户角色。我正在使用SQL数据库并在aspnet中工作。有人能建议如何实现吗?

你可以试试

String sql = "SELECT * FROM table_name WHERE [UserId] = 'REQUESTED_USERNAME' && [Password] = 'REQUESTED_PASSWORD'";

    string strCon = System.Web
                          .Configuration
                          .WebConfigurationManager
                          .ConnectionStrings["SocialSiteConnectionString"].ConnectionString;

    SqlConnection conn = new SqlConnection(strCon);
    SqlCommand comm = new SqlCommand(sql, conn);
    conn.Open();
    SqlDataReader nwReader = comm.ExecuteReader();
    while (nwReader.Read())
    {
        int UuserRole = (int)nwReader["UserROLE"];
    //do some stuffs

    }
    nwReader.Close();
    conn.Close();

你能详细说明你的问题吗?您正在使用MS/My SQL吗?数据库还是什么?刚刚用信息更新了我的原始问题谢谢你的解决方案。根据角色的不同,我如何使用它来隐藏面板?这真的很简单。使用if-else语句
html代码html代码