频道直达 - 专题 - 新闻 - 技巧 - 组网 - 开发 - 安全 - web编程 - 图像 - 操作系统 - 数据库 - 教育 - 旅游 - 健康 - 时尚 - 驱动 - 软件 - 游戏 - 多媒体 - ERP - 讨论组

在ASP.NET中创建安全的web站点

来源:enet 作者:74.COM.CN 出处:巧巧读书 2005-11-27 进入讨论组
上一页 1 2 3 4 
引用:http://www.qqread.com/aspdotnet/e620988000.html/// <summary>
  /// Verifies the login and password that were given
  /// </summary>
  /// <param name="email">the login</param>
  /// <param name="password">the password</param>
  /// <param name="nLoginID">returns the login id</param>
  /// <param name="nLoginType">returns the login type</param>
  public void Login(string email, string password, ref int nLoginID, ref int nLoginType)
  {
  ResetSql();
  DataSet ds = new DataSet();
  // Set our parameters
  SqlParameter paramLogin = new SqlParameter("@username", SqlDbType.VarChar, 100);
  paramLogin.Value = email;
  SqlParameter paramPassword = new SqlParameter("@password", SqlDbType.VarChar, 20);
  paramPassword.Value = password;
  Command.CommandType = CommandType.StoredProcedure;
  Command.CommandText = "glbl_Login";
  Command.Parameters.Add(paramLogin);
  Command.Parameters.Add(paramPassword);
  Adapter.TableMappings.Add("Table", "Login");
  Adapter.SelectCommand = Command;
  Adapter.Fill(ds);
  if(ds.Tables.Count != 0)
  {
  DataRow row = ds.Tables[0].Rows[0];
  // Get the login id and the login type
  nLoginID = Convert.ToInt32(row["Login_ID"].ToString());
  nLoginType = Convert.ToInt32(row["Login_Type"].ToString());
  }
  else
  {
  nLoginID = 0;
  nLoginType = 0;
  }
  }
  }
  abstract public class CSql
  {
  private SqlConnection sqlConnection; // Connection string
  private SqlCommand sqlCommand; // Command
  private SqlDataAdapter sqlDataAdapter; // Data Adapter
  private DataSet sqlDataSet; // Data Set
  public CSql()
  {
  sqlConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
  sqlCommand = new SqlCommand();
  sqlDataAdapter = new SqlDataAdapter();
  sqlDataSet = new DataSet();
  sqlCommand.Connection = sqlConnection;
  }
  /// <summary>
  /// Access to our sql command
  /// </summary>
  protected SqlCommand Command
  {
  get { return sqlCommand; }
  }
  /// <summary>
  /// Access to our data adapter
  /// </summary>
  protected SqlDataAdapter Adapter
  {
  get { return sqlDataAdapter; }
  }
  /// <summary>
  /// Makes sure that everything is clear and ready for a new query
  /// </summary>
  protected void ResetSql()
  {
  if(sqlCommand != null)
  {
  sqlCommand = new SqlCommand();
  sqlCommand.Connection = sqlConnection;
  }
  if(sqlDataAdapter != null)
  sqlDataAdapter = new SqlDataAdapter();
  if(sqlDataSet != null)
  sqlDataSet = new DataSet();
  }
  /// <summary>
  /// Runs our command and returns the dataset
  /// </summary>
  /// <returns>the data set</returns>
  protected DataSet RunQuery()
  {
  sqlDataAdapter.SelectCommand = Command;
  sqlConnection.Open();
  sqlConnection.Close();
  sqlDataAdapter.Fill(sqlDataSet);
  return sqlDataSet;
  }
  }
  } 更多文章 更多内容请看路由安全配置专题系统安全设置配置安全的操作系统专题,或进入讨论组讨论。
上一页 1 2 3 4 
收藏此文】【 】【打印】【关闭
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
巧巧读书宗旨
相关专题
讨论组问题推荐
站内各频道最新更新文档
站内最新制作专题
热门关键字导读
Photoshop教 程照片处理 照片制作 PS快捷键 抠图
计 算 机 故 障XP系统修复
艺 术 与 设 计设计 流媒体 设计欣赏 边框
计 算 机 安 全ARP
站内频道文章精选
巧巧电脑频道编辑信箱  告诉我们您想看的专题或文章