随笔分类 -  asp.net C#

一句SQL搞定查询并插入
摘要:Insertintotablename(字段1,字段2)Select字段1,字段2fromtablenameWhere(条件) 阅读全文

posted @ 2014-12-19 12:35 淡定的无奈 阅读(287) 评论(0) 推荐(0)

遍历内存中的缓存
摘要:System.Web.Caching.Cache _cache = HttpRuntime.Cache; IDictionaryEnumerator CacheEnum = _cache.GetEnumerator();//ArrayList al = new ArrayList(... 阅读全文

posted @ 2014-12-11 12:20 淡定的无奈 阅读(172) 评论(0) 推荐(0)

vs2012调试时使用传统经典模式
摘要:vs2012调试时默认会是集成模式,vs2012调试时怎么使用传统模式哪?这个时候只要选中解决方案按F4,在托管管道模式里选传统模式即可! 阅读全文

posted @ 2014-12-09 15:54 淡定的无奈 阅读(2277) 评论(0) 推荐(0)

sql server log日志文件减少的方法
摘要:随着时间的推移,你会发现数据库的日志文件会多达20G或更多,这时候你就需要以下方法了。-- 首先把数据库的恢复模式改为SimpleALTER DATABASE [数据库] SET RECOVERY SIMPLE;GO-- 缩小log文件至1M,逻辑名称可以通过sp_helpfile拿到DBCC SH... 阅读全文

posted @ 2014-12-08 16:20 淡定的无奈 阅读(534) 评论(0) 推荐(0)

下载Excel
摘要://this.export_data.InnerHtml = sb.ToString(); Response.Clear(); Response.Buffer = true; Response.Charset = "utf-8"; Response.AppendHeader("Content-Disposition", "attachment;filename=RMA" + sdate + "-" + edate + ".xls"); Response.ContentEncoding = Sys 阅读全文

posted @ 2014-02-19 16:10 淡定的无奈 阅读(144) 评论(0) 推荐(0)

string.Format的用法
摘要:String where = "u_username='{0}' and u_password='{1}'";where = string.Format(where,loginuser,password); IList<users> userslist=usersBLL.Select(where,true,false); 阅读全文

posted @ 2013-04-25 10:31 淡定的无奈 阅读(155) 评论(0) 推荐(0)

dataset 转json
摘要:DataSet set = WebData1.dataSet(sql); JsonSerializerSettings settings = newJsonSerializerSettings(); settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; StrResult = JsonConvert.SerializeObject(new { xdn = set }, Formatting.Indented, settings); 阅读全文

posted @ 2013-01-25 13:19 淡定的无奈 阅读(315) 评论(0) 推荐(0)

linq 查询
摘要:linq 分组查询:var qs = CC_.GroupBy(x => new { x.customer_name,x.sales_account,x.customer_code }).Where(Items=>Items.Key.sales_account==sales);linq 拼接:var q = from n in CC_ select n; if (keys=="none"&& keys1=="") { q = q.Where(p => p.sales_account==sales); }... 阅读全文

posted @ 2013-01-07 13:08 淡定的无奈 阅读(230) 评论(0) 推荐(0)

海量数据,SQL查询优化
摘要:1、应尽量避免在 where 子句中使用 or 来连接条件,否则将导致引擎放弃使用索引而进行全表扫描,如:select id from t where num=10 or num=20可以这样查询:select id from t where num=10union allselect id from t where num=202、应尽量避免在 where 子句中使用!=或<>操作符,否则将引擎放弃使用索引而进行全表扫描。3、对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引。4、应尽量避免在 where 子句中对字段进行 nu 阅读全文

posted @ 2012-11-20 13:22 淡定的无奈 阅读(226) 评论(0) 推荐(0)

asp.net 页面事件及处理顺序
摘要:Page_PreInit使用IsPostBack属性确定是否是第一次处理该页;创建动态控件;动态设置Theme属性;读取或设置配置文件属性值等Page_Init读取或初始化控件属性Page_Preload事件在所有回发数据处理之后但在 Load 事件之前引发Page_Load读取和更新控件属性Controlevents处理特定事件,如 Button 控件的 Click 事件Page_PreRender对页的内容进行最后更改Page_Unload 执行最后的清理工作,例如关闭打开的文件和数据库连接等以下代码可以用于验证这些事件的触发顺序protected void Page_Load(objec 阅读全文

posted @ 2012-11-14 22:52 淡定的无奈 阅读(409) 评论(0) 推荐(0)

c#设计模式-工厂模式
摘要:http://www.cnblogs.com/guyuehuanhuan/archive/2011/01/31/1948119.html利用设计模式能够使我们的代码更灵活,更容易扩展,更容易维护。各种面向对象的程式设计语言都提供了基本相同的机制:比如类、继承、派生、多态等等。但是又有各自的特色,C# 中的反射机制便是个很重要的工具,好好地利用就能够在实际中发挥很大的作用。 我们来看一个例子: 我的程式中有需要一系列的对象,比如apple,orange…, 要想利用他们,我们就必须在程式中根据用户需要,然后一个个调用 new 操作符来生成他们,这样客户程式就要知道相应的类的信息,生成... 阅读全文

posted @ 2012-11-12 22:12 淡定的无奈 阅读(221) 评论(0) 推荐(0)

Linq 多件拼接
摘要:var q = from n in CC_ select n; if (keys=="none") { q = q.Where(p => p.sales_account==sales); } if (keys1 != "") { q = q.Where(p => p.customer_name.Contains(keys1) || p.customer_code.Contains(keys1)); } 阅读全文

posted @ 2012-10-19 19:00 淡定的无奈 阅读(160) 评论(0) 推荐(0)

C# 将数据保存到内存
摘要:Cache.Insert("Vender", set, null, DateTime.Now.AddHours(0.1), TimeSpan.Zero); //将数据保存到内存 DataSet ds1 = (DataSet)HttpContext.Current.Cache["Vender"]; //从内存中获取数据 阅读全文

posted @ 2012-10-19 18:58 淡定的无奈 阅读(1644) 评论(0) 推荐(0)

导航