/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.ipAccess model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into dt_IpAccess("); strSql.Append("IP_Address,IP_DateTime)"); strSql.Append(" values ("); strSql.Append("@IP_Address,@IP_DateTime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@IP_Address", SqlDbType.NVarChar, 100), new SqlParameter("@IP_DateTime", SqlDbType.DateTime) }; parameters[0].Value = model.iP_Address; parameters[1].Value = model.iP_DateTime; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
protected void Application_Start(object sender, EventArgs e) { #region 记录网站访问 BLL.ipAccess bll_ipAccess = new BLL.ipAccess(); Model.ipAccess entity = new Model.ipAccess(); entity.iP_Address = DTRequest.GetIP(); entity.iP_DateTime = DateTime.Now; if (!bll_ipAccess.Exists(entity.iP_Address)) { bll_ipAccess.Add(entity); } #endregion }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.ipAccess model) { return(dal.Add(model)); }