摘要: summary> /// 字符串转16进制字节数组 /// /// /// //十六进制组成的字符串转成byte[]private static byte[] strToToHexByte(string hexString) { hexString = hexString.Replace(" ", ""); if ((hexString.Length % 2) != 0) hexString += " "; byte[] returnBytes = new byte[hexString.Length / 2]; for (int 阅读全文
posted @ 2013-07-29 15:36 returnKing 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 1.js代码function uploadFile() { var str = '' document.getElementById('MyFile').insertAdjacentHTML("beforeEnd", str) }2.页面含义html代码(页面必须含有一个runat=“server”的file对象) 3.后台页面代码 public bool attachfileupload() { Hashtable ht = new Hashtable(); HttpFileCollection files = HttpContext.Cu 阅读全文
posted @ 2013-07-29 11:44 returnKing 阅读(316) 评论(0) 推荐(0) 编辑
摘要: 首先建立一个超链接其中超链接href转到Download.aspx,接着,在DownloadFile.aspx页面中使用string fileid = Request.QueryString["fileid"]; string filename = Request.QueryString["filename"]; string filepathname = Server.MapPath(@"~/upload/") + fileid; Response.Clear(); Response.ClearHeade... 阅读全文
posted @ 2013-07-29 11:38 returnKing 阅读(1711) 评论(0) 推荐(0) 编辑
摘要: 1.对于txt,html等文本文件可以使用streamreader的方式读取,生成string类型2.对于图像、图片类型则使用filestream的方式读取后生成byte[]3.对于response.writefile("path"),则是把文件内容读取到响应输出流(内容可以是一个jpp文件,或者是html,txt文件等等) 阅读全文
posted @ 2013-07-25 10:19 returnKing 阅读(198) 评论(0) 推荐(0) 编辑
摘要: .NET二进制图片存储与读取的常见方法有以下几种:.NET二进制图片存储:以二进制的形式存储图片时,要把数据库中的字段设置为Image数据类型(SQL Server),存储的数据是Byte[].1.参数是图片路径:返回Byte[]类型:publicbyte[] GetPictureData(string imagepath) { /**/////根据图片文件的路径使用文件流打开,并保存为byte[] FileStream fs = new FileStream(imagepath, FileMode.Open);//可以是其他重载方法 byte[] byData = newbyte[fs... 阅读全文
posted @ 2013-07-25 10:12 returnKing 阅读(359) 评论(0) 推荐(0) 编辑
摘要: 1、创建事务的结构SqlConnection sqlConnection = new SqlConnection(); ...初始化连接 // 开启事务 SqlTransaction sqlTransaction = sqlConnection.BeginTransaction(); // 将事务应用于Command SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.Transaction = sqlTransaction; try { //... 阅读全文
posted @ 2013-07-23 09:18 returnKing 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 初学数据库编程我们可能会有一些对“空值”的疑问,比如通过编程新建的一个表中所有数据皆显示为,手动添加并删除文字后又变成了空白;一个字符串类型的字段,明明没有填值,却不等于"";用ADO.NET从数据库中取值,每遇到有的就出错……这需要我们正确认识.NET和SQL Server中几种不同的“空值”。 1、真正的空值,也就是“没有输入的值”,可以出现在大多数类型的字段中(如果没有别的约束条件),SQL server中表示为null,显示为,手工在SQL server企业管理器中输入的方法是按Ctrl+0。它在.NET中对应System.DBNull.Value。在T-SQL命令 阅读全文
posted @ 2013-07-22 08:39 returnKing 阅读(1022) 评论(0) 推荐(0) 编辑
摘要: Response.Charset ASP.NET 中示例: CodePage 告诉 IIS 按什么编码来读取 QueryString,按什么编码转换数据库中的内容……Response.ContentEncoding获取或设置输出流的 HTTP 字符集。Response.Charset获取或设置输出流的 HTTP 字符集。微软对 ContentEncoding、Charset 的解释是一字不差,其实可以这样理解:ContentEncoding 是标识这个内容是什么编码的,而 Charset 是告诉客户端怎么显示的。我们可以做一个实验来理解:实验1.Response.ContentEncodi.. 阅读全文
posted @ 2013-07-19 15:57 returnKing 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 1. //服务器端rendercontrol生成word文档 #region //HttpContext.Current.Response.Clear(); //HttpContext.Current.Response.Charset = "UTF-8"; //HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=导出文档.doc"); //HttpContext.Current.Response.ContentEnco 阅读全文
posted @ 2013-07-19 15:47 returnKing 阅读(232) 评论(0) 推荐(0) 编辑
摘要: function areaword(value) { var wd = new ActiveXObject("Word.Application"); var doc = wd.Documents.Add("", 0, 1); var range = doc.Range(0, 1); var sel = document.body.createTextRange(); sel.moveToElementText(value); sel.select(); sel.execCommand("Copy"); range.Paste(); w 阅读全文
posted @ 2013-07-19 11:31 returnKing 阅读(262) 评论(0) 推荐(0) 编辑