摘要: 以下两段语句最终效果均为用数据库插入数据,请先对比观察它们的不同:string sql = string.Concat(new object[] {"insert into 表名(字段1,字段2) values('",值1,"','",值2,"')"});string sql = "insert into 表名(字段1,字段2) values('"+值1+"','"+值2+"')";以上两条语句的结果是相同的,但 阅读全文
posted @ 2013-01-07 10:56 yellowshorts 阅读(4020) 评论(0) 推荐(0) 编辑
摘要: 窗体控件中是有个List控件(ASP.Net)和一个ListView控件(WinForm)。 就以ListView为例子吧,ListView控件可以包含很多项,也可以说是一个集合,就让我们来看看它的Items属性吧!publicclassListView:Control{ publicListView.ListViewItemCollectionItems{get;} publicclassListViewItemCollection:IList,ICollection,IEnumerable{ } } ListView的Items类型是ListView.ListViewItemColle.. 阅读全文
posted @ 2013-01-07 10:48 yellowshorts 阅读(5129) 评论(0) 推荐(0) 编辑
摘要: string strcon = "Data Source=.\\SQLEXPRESS;Initial Catalog=Db_Example;Persist Security Info=True;User ID=sa;Password=sa";SqlConnection con = new SqlConnection(strcon);con.Open();string strsql = "select * from SC,Course where SC.Cno=Course.Cno";SqlDataAdapter da = new SqlDataAdapt 阅读全文
posted @ 2013-01-07 10:16 yellowshorts 阅读(1364) 评论(0) 推荐(0) 编辑
摘要: 方法1: string m_Str = "1984-04-04"; int m_Y1 = DateTime.Parse(m_Str).Year; int m_Y2 = DateTime.Now.Year; int m_Age = m_Y2 - m_Y1; Response.Write(m_Age);方法2: 如果你将日期格式化为yyyymmdd,并且从当前日子减去生日,最后去除4个数字,就得到年龄了:) 我相信这样的方法可以用任何语言实现: 20080814-19800703=280111 去除最后4位 =28. int now =int.Parse(DateTime... 阅读全文
posted @ 2013-01-06 11:03 yellowshorts 阅读(15124) 评论(0) 推荐(0) 编辑
摘要: DateTimedtTemp;stringstrTemp="2012-12-12";boolisDate=DateTime.TryParse("strTemp",outdtTemp); 阅读全文
posted @ 2012-12-27 13:40 yellowshorts 阅读(1188) 评论(0) 推荐(0) 编辑
摘要: from u in usergroups from p in u.UsergroupPricesselect new UsergroupPricesList { UsergroupID= u.UsergroupID, UsergroupName= u.UsergroupName, Price= p.Price }Left Join var query =from u in usergroups join p inUsergroupPrices on u equals p.UsergroupIDinto gj from x in gj.DefaultIfEmpty()selectne... 阅读全文
posted @ 2012-12-13 16:40 yellowshorts 阅读(2717) 评论(0) 推荐(0) 编辑
摘要: FTP 上传出现错误 :The directory '/App_Code/' is not allowed because the application is precompiled.解决方法:这样的错误通常是由于网站是发布后上传至服务器,而App_Code文件夹里的文件没有删除也传到服务器上去了,其实编译后App_Code的资源已经在DLL里了,所以不必上传App_Code里的文件,否则会引起如上错误。 阅读全文
posted @ 2012-12-13 16:15 yellowshorts 阅读(825) 评论(0) 推荐(0) 编辑
摘要: 当用户浏览网页的时候会在某个地方需要用户登陆才能继续浏览,用户登陆之后会自动跳转到刚刚浏览的页面。这个步骤是怎么实现的呢?net小伙在查阅相关资料实践之后终于明白了,其实很简单,先分享给大家吧。 当用户在浏览一个页面的时候,如果需要登录,就在此页面记录当前的URL,然后传到都登录页面,登录成功之后,通过接收的值返回到上一个页面。这里有两种方法: ①:通过页面传值的方法: 先获取当前页面的URL:string url =Request.UrlReferrer; 通过代码进行传值:Response.Redirect( "/login.aspx?url= "+System.Web 阅读全文
posted @ 2012-12-10 11:07 yellowshorts 阅读(3396) 评论(0) 推荐(1) 编辑
摘要: C#代码与javaScript函数的相互调用:1.如何在JavaScript访问C#函数?2.如何在JavaScript访问C#变量?3.如何在C#中访问JavaScript的已有变量?4.如何在C#中访问JavaScript函数?问题1答案如下:javaScript函数中执行C#代码中的函数:方法一:页面和页面类相结合1、函数声明为public 后台代码(把public改成protected也可以) public string ss() { return("a"); }2、在html里用<%=ss()%>可以调用//是C#中后台的函数名称 前台脚本 <s 阅读全文
posted @ 2012-11-29 11:00 yellowshorts 阅读(329) 评论(0) 推荐(0) 编辑
摘要: 网上摘录前台:<html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>CallBack</title> <script language="javascript" type="text/javascript"> function turnPage(pageIndex) { CallServer(pageIndex, ' 阅读全文
posted @ 2012-11-28 11:14 yellowshorts 阅读(258) 评论(0) 推荐(0) 编辑