c#读取excel导入到数据库中
摘要:读取excel /// <summary> /// 从选择的excel导入 /// </summary> /// <returns></returns> public DataSet ImportExcel() { //文件路径 string ExcelName = ofd_in.FileName; string strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ExcelName + ";E...
阅读全文
posted @
2012-12-19 13:26
jameshappy
阅读(10426)
推荐(1)
由DataSet导出生成excel的几种方法
摘要:1、当dataset中包含了html等特殊字符用这个处理public void CreateExcel2(DataSet ds) { //创建一个excel application Excel.Application xls_exp=null; int rowindex=1; int colindex=0; //创建一个workbook,一个worksheet Excel._Workbook xls_book=null; Excel._Worksheet xls_sheet=null; ...
阅读全文
posted @
2012-12-18 09:33
jameshappy
阅读(3113)
推荐(0)
asp.net C# 获得配置文件AppSettings 的值
摘要:using System.Configuration;//导入命名空间 //配置文件 Web.config <appSettings> <!--数据连接字符串--> <add key="SqlConnectionStr" value="server=.;uid=sa;pwd=sa;database=RCCMS"/> </appSettings> //在程序里获得配置文件的Key对应的值 System.Configuration.ConfigurationSettings.AppSettings["
阅读全文
posted @
2012-11-29 11:17
jameshappy
阅读(16594)
推荐(0)
Url传值编码UrlEncode和解码UrlDecode
摘要:url传汉字出现乱码解决办法对汉字进行编码和解码页面1Response.Redirect("Default2.aspx?para1="+HttpUtility.UrlEncode("中国你好数据")+"¶2=数据的方式的");页面2this.Label1.Text = Request["para2"].ToString(); //没有解码操作this.Label2.Text = System.Web.HttpUtility.UrlDecode(Request["para1"].T
阅读全文
posted @
2012-11-21 17:17
jameshappy
阅读(628)
推荐(0)
将字符串转化为gb2312字符
摘要:string utfinfo = getpage; string gb2312info = string.Empty; Encoding utf8 = Encoding.UTF8; Encoding gb2312 = Encoding.GetEncoding("gb2312"); // Convert the string into a byte[]. byte[] unicodeBytes = utf8.GetBytes(utfinfo); ...
阅读全文
posted @
2012-11-21 17:13
jameshappy
阅读(1203)
推荐(0)
C#实现MD5加密
摘要:using System.Security.Cryptography; /// <summary> /// MD5 16位加密 /// </summary> /// <param name="ConvertString"></param> /// <returns></returns> public static string GetMd5Str16(string ConvertString) { MD5CryptoServiceProvider md5 =...
阅读全文
posted @
2012-10-09 16:08
jameshappy
阅读(342)
推荐(0)
实现json的序列化和反序列化
摘要://实现json的序列化和反序列化 Person Person = new Person(); Person.Id = 1; Person.Name = "小白"; DataContractJsonSerializer json = new DataContractJsonSerializer(Person.GetType()); string szJson = ""; //序列化 using (MemoryStream stream = new MemoryStream()) { jso...
阅读全文
posted @
2012-09-17 10:32
jameshappy
阅读(423)
推荐(0)
实现http访问
摘要://实现http访问 try { string getpage = @"http://192.168.0.36:8082/News/PlusNews.aspx"; CookieContainer cc = new CookieContainer(); string content = string.Empty; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(getpage); request.Method = "post"; ...
阅读全文
posted @
2012-09-17 10:30
jameshappy
阅读(310)
推荐(0)
读取Oracle中的clob字段
摘要:int actual = 0; string strSql = "select producthtml from web_goods where productsn=835"; OracleDataReader reader= OraHelper.ExecuteReader(OraHelper.CONN_STRING, CommandType.Text, strSql, null); while (reader.Read()) { OracleLob myOracleClob = reader.GetOracleLob(0); StreamReader streamread
阅读全文
posted @
2012-09-13 15:59
jameshappy
阅读(1624)
推荐(0)
读取文件夹中的文件并修改数据库中的数据
摘要:OraHelper OraHelper = new OraHelper(); private void btnRead_Click(object sender, EventArgs e) { string[] strFiles = Directory.GetFiles(@"E:\网站\百联项目\goodshtml"); string strProductid = string.Empty; string strSql = string.Empty; string output = string.Empty; foreach(string strFile in strFile
阅读全文
posted @
2012-09-13 10:50
jameshappy
阅读(274)
推荐(0)
web打印 window.print()
摘要:我只给出比较有效的,方便的打印方法,有些WEB打印是调用ActiveX控件的,这样就需要用户去修改自己IE浏览器的Internet选项里的安全里的ActiveX,将它们全部启用,有些麻烦,翻了下网络,下面的方法是可以直接打印,而不会去修改IE的Internet选项。 window.print来打印页面,页面上别的元素也会被打印处理,页头页尾的格式也不好控制。• 常用方法:大部分情况会把查询的结果绑定到DataGrid上来,然后打印DataGrid。这种情况的打印一般来说格式比较固定简单,确定后基本不会再作更改。所以可以采用IE直接打印。【实例代码】注:①这是客户端通过window.print打
阅读全文
posted @
2012-04-13 10:26
jameshappy
阅读(1248)
推荐(0)
压缩上传及导出csv文件
摘要:#region 压缩 public static void RARsave(string patch, string rarPatch, string rarName) { String the_rar; RegistryKey the_Reg; Object the_Obj; String the_Info; ProcessStartInfo the_StartInfo; Process the_Process; try { the_Reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\
阅读全文
posted @
2012-04-05 17:26
jameshappy
阅读(703)
推荐(0)
生成缩略图和添加水印
摘要:using System.IO;using System.Drawing.Imaging;using System.Drawing;using System.Collections;/// <summary> /// 生成缩略图 /// </summary> /// <param name="Width">缩略图的宽度</param> /// <param name="Height">缩略图的高度</param> /// <param name="targetFile
阅读全文
posted @
2012-04-05 17:13
jameshappy
阅读(197)
推荐(0)
c/s中绑定combobox
摘要:private void GetTaskType() { //初始化任务类型 string sqlT = "select null codeitemsn,null codeitemname from dual union all select codeitemsn,codeitemname from sys_codeitem where codesn in ( "; sqlT += "select codesn from sys_code where codeid='TASKTYPE')"; WebCrm cm = new WebCrm(
阅读全文
posted @
2011-10-07 13:49
jameshappy
阅读(352)
推荐(0)
asp.net中打开新窗口
摘要:Response.Write("<script>window.open('test.aspx');</script>");
阅读全文
posted @
2011-08-18 13:41
jameshappy
阅读(184)
推荐(0)
javascript浮点运算问题
摘要:在判断浮点运算结果前对计算结果进行精度缩小,因为在精度缩小的过程总会自动四舍五入;(1.0-0.9).toFixed(digits) toFixed() 精度参数须在 0 与20 之间 如 (1.0-0.9).toFixed(10)==0.1 ,结果为True
阅读全文
posted @
2011-07-26 11:13
jameshappy
阅读(154)
推荐(0)
随机数生成
摘要:for (int j = 0; j < 8; j++) { String charOrNum = ran.Next(2) % 2 == 0 ? "char" : "num"; // 输出字母还是数字 if (charOrNum=="char") // 字符串 { int choice = ran.Next(2) % 2 == 0 ? 65 : 97; //取得大写字母还是小写字母 val += (char)(choice + ran.Next(26)); } else // 数字 { val += ran.Next(10).To
阅读全文
posted @
2011-07-21 12:41
jameshappy
阅读(212)
推荐(0)
C#实现AES加密和解密函数原代码
摘要:AES简介AES(The Advanced Encryption Standard)是美国国家标准与技术研究所用于加密电子数据的规范。它被预期能成为人们公认的加密包括金融、电信和政府数字信息的方法。AES 是一个新的可以用于保护电子数据的加密算法。明确地说,AES 是一个迭代的、对称密钥分组的密码,它可以使用128、192 和 256 位密钥,并且用 128 位(16字节)分组加密和解密数据。与公共密钥密码使用密钥对不同,对称密钥密码使用相同的密钥加密和解密数据。通过分组密码返回的加密数据 的位数与输入数据相同。迭代加密使用一个循环结构,在该循环中重复置换(permutations )和替换(
阅读全文
posted @
2011-04-28 15:37
jameshappy
阅读(792)
推荐(0)
Cookie 学习笔记
摘要:Cookie 是一小段文本信息,伴随着用户请求和页面在 Web 服务器和浏览器之间传递。Cookie 包含每次用户访问站点时 Web 应用程序都可以读取的信息。大多数浏览器支持最大为 4096 字节的 Cookie。编写Cookie方法一Response.Cookies["userName"].Value = "patrick";Response.Cookies["userName"].Expires = DateTime.Now.AddDays(1);方法二HttpCookie aCookie = new HttpCookie(&q
阅读全文
posted @
2011-04-28 15:21
jameshappy
阅读(178)
推荐(0)
having子句
摘要:在 SQL 中增加 HAVING 子句原因是,WHERE 关键字无法与合计函数一起使用查一张表中某个字段中的数据相同的记录:select 字段值,count(*) from table group by 字段值 having count(*)> 1alter table 表名 add constraint cpncode_unique unique (字段)
阅读全文
posted @
2011-04-12 14:27
jameshappy
阅读(191)
推荐(0)