当前位置: 代码迷 >> ASP.NET >> SqlDataReader有关问题
  详细解决方案

SqlDataReader有关问题

热度:7008   发布时间:2013-02-25 00:00:00.0
SqlDataReader问题
using   System;
using   System.Data;
using   System.Data.SqlClient;
using   System.Configuration;
using   System.Collections;
using   System.Web;
using   System.Web.Security;
using   System.Web.UI;
using   System.Web.UI.WebControls;
using   System.Web.UI.WebControls.WebParts;
using   System.Web.UI.HtmlControls;

public   partial   class   manage_loginchek   :   System.Web.UI.Page
{
        BaseClass   bc   =   new   BaseClass();
        protected   void   Page_Load(object   sender,   EventArgs   e)
        {

                string   p_id   =   Request.Params[ "uid "].Trim();
                string   p_pass   =   Request.Params[ "pwd "].Trim();
                SqlConnection   conn   =   new   SqlConnection(ConfigurationManager.AppSettings[ "conn "]);
                string   tSQL   =   "select   u_name,u_flag   from   users   where   u_id= ' "+p_id+ " '   and   u_pass= ' "+p_pass+ " 'order   by   id   desc   ";
                try
                {
                        SqlCommand   mycommand   =   new   SqlCommand(tSQL,   conn);
                        conn.Open();
                        SqlDataReader   reader   =   mycommand.ExecuteReader();
                        Session[ "name "]   =   reader[ "u_name "].ToString();
                        Session[ "flag "]   =   reader[ "u_flag "].ToString();
                }
                catch   (System.Exception   e)
                {
                        conn.Close();
                        Response.Redirect( "login.aspx ");
                }
                      //if   (s   ==   1)
                //{
                //         Session[ "flag "]   =   p_id;
                //         Response.Redirect( "adminindex.aspx ");

                //}

        }
}

大家看下,为什么会出错呢?

错误 1 不能在此范围内声明名为“e”的局部变量,因为这样会使“e”具有不同的含义,而它已在“父级或当前”范围中表示其他内容了 c:\inetpub\wwwroot\federal_wh\manage\loginchek.aspx.cs 31 9 http://localhost/federal_wh/