马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
前几天同学问我学习方向的问题。有点想法,不知道对不对,怕误导同学,现在“开源一下”。注:括号内是我现在整理的时填加上的。- usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;usingSystem.Data.SqlClient;publicpartialclass_Default:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){stringconnStr="Server=.;Database=Test;uid=sa";SqlConnectionconn=newSqlConnection(connStr);SqlCommandcomm=newSqlCommand("selectNowDtfromTable1whereDtId=1",conn);System.DateTimeaa;//数据库中存的工夫System.DateTimebb;//以后工夫//取数据库中工夫,字段是varChar范例try{conn.Open();aa=Convert.ToDateTime(comm.ExecuteScalar().ToString());//数据库工夫,object转为string转换为DateTimeconn.Close();}catch(Exceptionexp){throwexp;}finally{conn.Dispose();comm.Dispose();}this.HLOldDt.Text=aa.ToString();//输入数据库中工夫bb=System.DateTime.Now;//以后工夫this.HLNowDt.Text=bb.ToString();//输入以后工夫//时差stringss=this.DateDiff(aa,bb);this.HLSe.Text=ss.ToString();//输入工夫差}}//对照工夫差privatestringDateDiff(DateTimeDateTime1,DateTimeDateTime2){stringdateDiff=null;try{TimeSpants1=newTimeSpan(DateTime1.Ticks);TimeSpants2=newTimeSpan(DateTime2.Ticks);TimeSpants=ts1.Subtract(ts2).Duration();//求工夫差的相对值//构建工夫字符串dateDiff=ts.Days.ToString()+"天"+ts.Hours.ToString()+"小时"+ts.Minutes.ToString()+"分钟"+ts.Seconds.ToString()+"秒";}catch{}returndateDiff;}}
复制代码 2003年中微软发布最新版本的ASP.netWebMatrix,对于我们喜欢用Asp.net来编程的朋友实在是个好消息,我也实实在在的将Asp.net更深入的研究了一下,以方便我以后更好的运用它,同时我也讲讲使用它的感受。 |