文章分类 - asp.net(c#)
摘要:数据库操作类:复制代码 代码如下:/// <summary> /// 取得总数 /// </summary> /// <returns></returns> public string getTotal() { StringBuilder sb = new StringBuilder(); sb.Append("select count(*) tot...
阅读全文
posted @ 2010-03-23 12:45
PROS
摘要:在坛子里经常看到一些关于Session的问题,下面做一个总结,希望对大家有所帮助:问:为什么Session在有些机器上偶尔会丢失?答:可能和机器的环境有关系,比如:防火墙或者杀毒软件等,尝试关闭防火墙。问:为什么当调用Session.Abandon时并没有激发Session_End方法?答:首先Session_End方法只支持InProc(进程内的)类型的Session。其次要激发Session_...
阅读全文
posted @ 2010-03-23 09:59
PROS
摘要:构造器的理解 如果要你创建一个由21个"A"字符构成的字符串,你会怎么做?C# CODEstring str = "AAAAAAAAAAAAAAAAAAAAA";//老实型string str = new string('A', 21);//简单聪明
阅读全文
posted @ 2010-03-23 09:56
PROS
摘要:方法一:C# CODEstatic void Main() { string s = "123456789"; SwapChar(ref s, 3, 6); Console.Write(s.ToString()); } static void SwapChar(ref string s, int i1, int i2) { char temp = s[i1]; char temp1 = s[i2]...
阅读全文
posted @ 2010-03-23 09:55
PROS
摘要:CODE:string sql = "SELECT id,name FROM content FOR XML AUTO,XMLDATA";SqlConnection conn =new SqlConnection( System.Configuration.ConfigurationSettings.AppSettings["testDataBase"] );SqlCommand cmd=new ...
阅读全文
posted @ 2010-03-23 09:54
PROS
摘要:这又是一个经常遇到的问题。保留2位有效小数(和保留N位一样的参数不同而已):C# CODE static void Main() { Double a = 12.345678; Console.Write(Math.Round(a,2)); }//(将输出 12.35)四舍五入:static void Main() { Double a = 12.345678;//是要四舍五入的数 Console...
阅读全文
posted @ 2010-03-23 09:53
PROS
摘要:1.using指令。using + 命名空间名字,这样可以在程序中直接用命令空间中的类型,而不必指定类型的详细命名空间,类似于Java的import,这个功能也是最常用的,几乎每个cs的程序都会用到。例如:using System; using System.Data;2.using别名。using + 别名 = 包括详细命名空间信息的具体的类型。这种做法有个好处就是当同一个cs引用了两个不同的命...
阅读全文
posted @ 2010-03-23 09:52
PROS
摘要:方法一:C# CODE string a = "123456789"; a = int.Parse(a).ToString("##-###-####"); Console.Write(a);方法二:C# CODEstring a = "123456789"; a = a.Insert(5, "-").Insert(2, "-"); Console.Write(a);方法三:C# CODEusing...
阅读全文
posted @ 2010-03-23 09:52
PROS
摘要:我们可以把12 33 456 12342 拼起来就是一个字符,因为很多时候我们觉得处理只有几个组的时候用数组很麻烦所以我们用“|”或者“,”等等把他们拼起来在需要的时候用Split打散即可。下面列举一些用法,不做性能分析了。 方法一: C# CODEstatic void Main(string[] args) { string aa = "1234...
阅读全文
posted @ 2010-03-23 09:51
PROS
摘要:1.设置web.config文件。 <system.web> ...... <globalization requestEncoding="gb2312" responseEncoding="gb2312" culture="zh-CN" fileEncoding="gb2312" /> ...... </system.web> 2.传递中文之前,将要传递的中文...
阅读全文
posted @ 2010-03-23 09:51
PROS
摘要:这2个方法都可以把把string解析为int,那么我们一定会有疑问:到底他们有什么区别?什么时候该用什么?性能如何等等。其实在2.0里还有Int32.TryParse也实现了同样的效果。 C# CODEusing System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication1{ clas...
阅读全文
posted @ 2010-03-23 09:50
PROS
摘要:private void btnVerification_Click(object sender, EventArgs e) { Regex reg = new Regex(@"^\d{17}(\d|X)"); string sTemp=tbVerification.Text; lbCardInfo.Items.Clear(); if (sTemp == string.Empty) { Messa...
阅读全文
posted @ 2010-03-23 09:48
PROS
摘要:上传图片到数据库using System;using System.Data;using System.Drawing;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebCo...
阅读全文
posted @ 2010-03-23 09:39
PROS
摘要:publicArrayListExcelSheetName(stringfilepath) { ArrayListal=newArrayList(); stringstrConn; strConn="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="+filepath+";ExtendedProperties=\"Excel8.0;HDR=Yes;IMEX=...
阅读全文
posted @ 2010-02-24 14:30
PROS
摘要:ASP.NET Chart control is powerful control you can use to add charting support to your web applications. Although chart controls are mainly used with ASP.NET forms it is not very hard to use them also ...
阅读全文
posted @ 2010-02-05 14:16
PROS
摘要:Resolution:1. Run devenv /resetuserdata in VS.NET command prompt2. Run devenv /installvstemplates in VS.NET command prompts
阅读全文
posted @ 2010-02-05 10:12
PROS
摘要:http://blog.csdn.net/fangxinggood/archive/2005/03/24/329253.aspx[代码]
阅读全文
posted @ 2010-01-19 15:42
PROS
摘要:http://www.cnblogs.com/Jinglecat/archive/2006/08/15/477472.htmlhttp://www.cnblogs.com/Jinglecat/archive/2006/08/26/487167.htmlexcel表格文档Book.xlsa b c1 2 31 2 31 3 4标签名称为abc放在项目根目录下.前台插入GridView...
阅读全文
posted @ 2010-01-19 15:16
PROS
摘要:http://www.cnblogs.com/dahuzizyd/archive/2007/04/11/CSharp_Excel_Report_Chart_All.htmlC#操作Excel进行报表开发系列共写了八篇,也已经有很久没有新东西了,现在整理一下,方便以后查阅,如果有写新的,会同时更新。需要注意的是因为Office的版本不同,实际的代码可能会有所不同,但是都是多几个,少几个参数,补上参数...
阅读全文
posted @ 2010-01-13 15:01
PROS
摘要:清空listboxListBox1.Items.Clear();设定listbox当前选项pordms.SelectedIndex = 0;
阅读全文
posted @ 2010-01-13 13:48
PROS