日期:2014-05-18  浏览次数:20405 次

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 ");

                //}