随笔分类 -  应用代码

摘要:/// <summary>/// 计算日期的间隔(静态类)/// </summary>public static class dateTimeDiff{ /// <summary> /// 计算日期间隔 /// </summary> /// <param name="d1">要参与计算的其中一个日期字符串</param> /// <param name="d2">要参与计算的另一个日期字符串</param> /// <returns>一个表示日期间 阅读全文
posted @ 2011-04-02 10:48 闭着眼睛想 阅读(16342) 评论(0) 推荐(0)
摘要:在处理一些数据时,我们希望能用“四舍五入”法实现,但是C#采用的是“四舍六入五成双”的方法,如下面的例子,就是用“四舍六入五成双”得到的结果:double d1 = Math.Round(1.25, 1);//1.2double d2 = Math.Round(1.24, 1);//1.2double d3 = Math.Round(1.26, 1);//1.3double d4 = Math.Round(1.35, 1);//1.4为了用C#来实现“四舍五入”,我写了下面的函数: /// <summary> /// 实现数据的四舍五入法 /// </summary> 阅读全文
posted @ 2011-02-28 14:46 闭着眼睛想 阅读(769) 评论(0) 推荐(0)
摘要:1、判断闰年与平年的方法 int intmonth;if(System.DateTime.IsLeapYear(System.DateTime.Now.Date.Year)==true) { intmonth=29; //闰年} else { intmonth=28; //平年}2、获取指定月份的天数格式为:System.DateTime.DaysInMonth(int 指定的年份,int 指定的月份); 一、当前月份的天数int idate=System.DateTime.DaysInMonth(System.DateTime.Now.Year,System.DateTime.Now.Mon 阅读全文
posted @ 2010-12-15 09:36 闭着眼睛想
摘要:比如:我们要对字符串 "123123" 进行加密 分别调用下面方法WEB写法: /// <summary> /// MD5加密方法一 /// </summary> /// <param name="password">要加密字符串</param> /// <returns>加密后字符串</returns> public str... 阅读全文
posted @ 2010-12-01 16:28 闭着眼睛想 阅读(1359) 评论(0) 推荐(0)
摘要:方法一:利用字符串截取拆分数组字符串脚本Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/----=============================================--Author:<lx>--Createdate:<... 阅读全文
posted @ 2010-11-26 11:37 闭着眼睛想 阅读(4944) 评论(0) 推荐(0)
摘要:SqlHelper类调用存储过程的方法有下面类似的两种类型:/// <param name="connectionString">A valid connection string for a SqlConnection</param>/// <param name="commandType">The CommandType (stored procedure,... 阅读全文
posted @ 2010-11-25 16:16 闭着眼睛想 阅读(4282) 评论(1) 推荐(1)
摘要:在VS2005|2008|2010中,经常会使用到ConfigurationSettings类来读取应用程序配置文件的信息,以获取数据库连接的字符串,但是,经常会出现如下的错误: 警告“System.Configuration.ConfigurationSettings.GetConfig(string)”已过时:“This method is obsolete... 阅读全文
posted @ 2010-11-25 15:31 闭着眼睛想
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--///<summary>///数据库中与C#中的数据类型对照///</summary>///<paramname="type"></param>///&... 阅读全文
posted @ 2010-11-25 15:05 闭着眼睛想
摘要:1.编码string state=Server.UrlEncode(stateName.Text.Trim());Response.Redirect("aaa.aspx?state="+state+""); 2.解码(aaa.aspx)string state= Server.UrlDecode(Request.QueryString["state"].ToString());是GB2312编码的... 阅读全文
posted @ 2010-11-08 10:33 闭着眼睛想
摘要:select getdate() 2004-09-12 11:06:08.177 举例如下: select CONVERT(varchar, getdate(), 120 ) 2004-09-12 11:06:08select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','') 2004... 阅读全文
posted @ 2010-10-11 09:52 闭着眼睛想 阅读(158) 评论(0) 推荐(0)
摘要:一、Xlsx files:[代码]"HDR=yes;"是说第一行是列名而不是数据。"HDR=No;"正好与前面的相反。把数据当做文本对待,使用这条连接当你想把所有的数据都当做文本对待时,覆盖Excel通常的猜测这列的数据类型。[代码]如果你想把列名也读到结果集中(使用“HDR=NO”尽管第一行是列名)并且列中的数据是数值型的,使用“IMEX=1”可必... 阅读全文
posted @ 2010-09-28 17:34 闭着眼睛想
摘要:1、在Asp页面首部<head>加入 以下为引用的内容:Response.Buffer = True Response.ExpiresAbsolute = Now() - 1 Response.Expires = 0 Response.CacheControl = "no-cache" Response.AddHeader "Pragma", "No-Cache"   2、在H... 阅读全文
posted @ 2010-06-30 11:29 闭着眼睛想 阅读(442) 评论(0) 推荐(0)
摘要:[代码]System.Collections.IDictionaryEnumeratorenumerator=objHashTablet.GetEnumerator();while(enumerator.MoveNext()){Console.WriteLine(enumerator.Key);Console.WriteLine(enumerator.Value);} 阅读全文
posted @ 2010-04-23 15:00 闭着眼睛想 阅读(146) 评论(0) 推荐(0)
摘要:常用号段如下:中国移动134.135.136.137.138.139.150.151.152.157.158.159.187.188 ,147(数据卡)中国联通130.131.132.155.156.185.186 中国电信133.153.180.189 CDMA 133,153正则如下:Code highlighting produced by Actipro CodeHighlighter (... 阅读全文
posted @ 2010-04-23 14:41 闭着眼睛想 阅读(663) 评论(0) 推荐(0)
摘要:最近在做一个winform的程序,考虑用Sqlite的数据库,小巧而实用,比Access强多了,不过需要加密,不过free版本没有实现加密,有一些c++的实现:比如:http://www.sqlite.com.cn/MySqlite/3/253.Html 和http://www.cppblog.com/niewenlong/archive/2007/06/01/25261.html 。不过,鉴于我... 阅读全文
posted @ 2010-04-12 14:41 闭着眼睛想 阅读(448) 评论(0) 推荐(0)
摘要:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--createprocp_getlinkinfo@dbnamesysname=null,--要查询的数据库名,默认查询所有数据库的连接信息@includeipbit=0--是否显示IP地址,因为查询IP地址... 阅读全文
posted @ 2010-03-02 16:02 闭着眼睛想 阅读(2311) 评论(0) 推荐(0)
摘要:代码如下 :创建一个触发器Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--USEmasterGOALTERTRIGGERtr_LoginCheckONALLSERVERFORLOGONASIFEVENTDATA().value('(/EVENT_INS... 阅读全文
posted @ 2010-03-02 15:53 闭着眼睛想 阅读(402) 评论(0) 推荐(0)
摘要:一、简介xp_cmdshell 扩展存储过程将命令字符串作为操作系统命令 shell 执行,并以文本行的形式返回所有输出。二、SQL Server 2005中的xp_cmdshell由于存在安全隐患,所以在SQL Server 2005中, xp_cmdshell 默认是关闭的。此时,如果执行 xp_cmdshell 将会提示服务未开启:exec xp_cmdshell 'dir c:\'消息 1... 阅读全文
posted @ 2010-03-02 15:50 闭着眼睛想 阅读(725) 评论(1) 推荐(0)
摘要:[代码] 阅读全文
posted @ 2010-02-23 09:40 闭着眼睛想 阅读(308) 评论(0) 推荐(0)
摘要:大家在做web开发的时候,经常会用到Session,最常用的就是登录功能了。用户登录后,Session["LoginName"]="userName";在其他页面再进行Session["LoginName"]的判断,用户状态是否过期等等。如果很多个页面,我们每个页面都要进行判断,岂不是要累死!我们可以用下面的方法来简化我们的工作:1、添加一个BasePage类,System.Web.UI.Page... 阅读全文
posted @ 2010-02-03 16:36 闭着眼睛想 阅读(248) 评论(0) 推荐(0)