随笔分类 -  ADO.NET

ADO.NET学习
摘要:需求:需要把D盘Source文件夹中的所有名称包含"LTE"的子文件夹Copy到E盘的Backup文件中,实现特定文件夹每天备份。步骤:1,遍历D盘Source文件夹找出所有名称包含LTE的文件,文件路径存放到List<string>中 2,遍历List<string>,把所有文件Copy到E盘的备份文件夹中实现效果:Copy→项目中借助txt文件存放源文件夹路径和目的文件夹路径,以便修改:解决方案截图:实现代码:using System;using System.Collections.Generic;using System.Linq;using 阅读全文
posted @ 2013-05-08 21:27 sirili 阅读(1629) 评论(5) 推荐(0)
摘要:HttpPostedFile UpFile = File1.PostedFile; int FileLenght = UpFile.ContentLength; decimal FileSize = FileLenght / 1024; if (FileLenght == 0) { DIVShowGVError.Visible = true; LblShowGVError.Text = "请选择上传文件"; retu... 阅读全文
posted @ 2013-04-01 12:27 sirili 阅读(355) 评论(0) 推荐(0)
摘要:public static DataTable ExcelToDataSet(string filename) { try { //string strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = " + filename + ";Extended Properties=Excel 8.0"; string strCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data ... 阅读全文
posted @ 2013-03-25 19:22 sirili 阅读(263) 评论(0) 推荐(0)
摘要:private void button1_Click(object sender, EventArgs e) { // 表名+TableAdapter 表名+DataTable 表名+Row ContactTableAdapter adapter = new ContactTableAdapter(); 强类型DateSet.AdventureWorksDataSet.ContactDataTable ContactTable = adapter.GetDataByNameStyle(true); //adap... 阅读全文
posted @ 2013-03-21 14:32 sirili 阅读(162) 评论(0) 推荐(0)
摘要:1.新建Golbal.asax void Application_Error(object sender, EventArgs e) { Exception objErr = Server.GetLastError().GetBaseException(); string error = "发生异常页: " + Request.Url.ToString() + "<br>"; error += "异常信息: " + objErr.Message + "<br>"; Server.ClearE 阅读全文
posted @ 2013-01-03 11:22 sirili 阅读(216) 评论(0) 推荐(0)
摘要:1,读取TXT写入DB步骤:打开连接——SqlCommand(Conn,Str)——逐行读取TXT文本 构造SqlParameter 的参数——执行ExecuteNonQuery()—— 清除参数2,乱码问题:Txt文档的编码要和StreamReader的编码一致:using (StreamReader streamReader = new StreamReader(file, Encoding.Default))//解决乱码问题using System;using System.Collections.Generic;using System.ComponentModel;using Sys 阅读全文
posted @ 2012-12-18 00:52 sirili 阅读(494) 评论(0) 推荐(0)
摘要:1,省的ID,Name直接定义成类,实例化后添加的到ComBox(DropDrownList)中,DisplayMember设置为ProName2,绑定后SelectedIndex=0,显示绑定的第一个值3,Configure中设置连接字符串,ConfigurationManager 中得到字符串的值using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text; 阅读全文
posted @ 2012-12-17 22:17 sirili 阅读(523) 评论(0) 推荐(0)