protected void Page_Load(object sender, EventArgs e) { string tempurl = Utils.GetStaticPageNumbersHtml(2, 100, "showforum", ".aspx", 8); DbParameter[] prams = { DbHelper.MakeInParam("@name", DbType.String, 3,"aabbccdd") }; DbHelper.ExecuteNonQuery(CommandType.Text, "INSERT INTO itca_test(name) VALUES (@name)", prams); DbDataReader dr = DbHelper.ExecuteReader(CommandType.Text, "SELECT * FROM wy_articles"); while (dr.Read()) { Response.Write(dr["title"].ToString()+"<br />"+ dr["content"].ToString()); } if (Request.QueryString["a"] != null) { Response.Write(Request.QueryString["a"].ToString()); } TinyCache tc = new TinyCache(); tc.AddObject("test", "bbbbb"); Response.Write("TinyCache:" + tc.RetrieveObject("test") as string); System.Collections.Generic.SortedList<int, object> list = new System.Collections.Generic.SortedList<int, object>(); list.Add(1, "协会公告"); list.Add(2, "协会新闻"); object aaaa = list[1]; }
protected void btnStart_Click(object sender, EventArgs e) { DbHelper.ResetDbProvider(); DbHelper.ConnectionString = @"Data Source=D:\Documents\DotNet\CvsPlace\itca\iTCA.Yuwen.Web\config\db.config"; DbHelper.Dbtype = "Sqlite"; TinyCache cache = new TinyCache(); DataTable dt = cache.RetrieveObject("dt") as DataTable; foreach (DataRow dr in dt.Rows) { int newid = 23; int newaid = newid + Convert.ToInt32(dr["n_id"]); int cid; switch (dr["n_class"].ToString().Trim()) { case "协会新闻": cid = 2; break; case "校园新闻": cid = 3; break; case "业内新闻": cid = 4; break; default: cid = 100; break; } DbParameter[] prams = { DbHelper.MakeInParam("@articleid", DbType.Int32, 4,newaid), DbHelper.MakeInParam("@title", DbType.String, 100,dr["n_title"]), DbHelper.MakeInParam("@columnid", DbType.Int32, 4,cid), DbHelper.MakeInParam("@content", DbType.String, 100,dr["n_content"]), DbHelper.MakeInParam("@postdate", DbType.DateTime, 8,dr["n_date"]), DbHelper.MakeInParam("@uid", DbType.Int32, 4,1), DbHelper.MakeInParam("@username", DbType.String, 20,dr["n_user"]) }; DbHelper.ExecuteNonQuery(CommandType.Text, "INSERT INTO wy_articles(articleid,columnid,title,uid,username,postdate,content) VALUES(@articleid,@columnid,@title,@uid,@username,@postdate,@content)", prams); } Response.Write("OK~"); }
/// <summary> /// 取得栏目列表 /// </summary> /// <returns></returns> public static List<ColumnInfo> GetColumnCollection() { List<ColumnInfo> coll; TinyCache cache = new TinyCache(); coll = cache.RetrieveObject("ColumnList") as List<ColumnInfo>; if (coll == null) { coll = new List<ColumnInfo>(); IDataReader reader = DatabaseProvider.GetInstance().GetArticleColumnList(); while (reader.Read()) { coll.Add(DataReader2ColumnInfo(reader)); } reader.Close(); cache.AddObject("ColumnList", coll); } return coll; }