摘要:
/// <summary> /// 自定义加密方法,该方法用来加密指定的字符串 /// </summary> /// <param name="str">要加密的字符串</param> /// <returns>返回加密后的字符串</returns> public string Encrypting(string str) { //把要加密的字符串存储到byte数组中 byte[] bytIn = System.Text.Encoding.Default.GetBytes(str); //创建加密对象的 阅读全文
摘要:
//定义Person类型数组 Person[] arr = new Person[] { new Person("小李",30,"软件开发"), new Person("小王",26,"软件开发"), new Person("小张",27,"软件测试") }; //投影操作,插入了索引值 var result = arr.Select((p, index) => new { index, p.P_name, p.P_dept ,p.P_age}); for... 阅读全文
摘要:
List<string> color = new List<string>() { "red", "yellow", "green", "black", "blue" }; //使用where子句 var result = from c in color where c.Length > 4 select c; //使用Where操作符 var result2 = color.Where(u => u.IndexOf("ll") > 阅读全文
摘要:
//创建XmlWriter实例 using (XmlWriter xw = XmlWriter.Create(Server.MapPath("user.xml"))) { xw.WriteComment("图书信息");//注释语句 //根节点开始 xw.WriteStartElement("Info"); //定义子节点Record xw.WriteStartElement("Record"); xw.WriteAttributeString(... 阅读全文
摘要:
//创建XmlReader实例 using (XmlReader xr = XmlReader.Create(Server.MapPath("info.xml"))) { while (xr.Read()) { //根据节点类型输出内容 switch (xr.NodeType) { case XmlNodeType.Element://节点开始符号及其属性 Response.Write(... 阅读全文
摘要:
SerchXMLprotected void btnSelect_Click(object sender, EventArgs e) { XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("book.xml"));//加载XML文件 XmlNodeList nodes; XmlElement root = doc.DocumentElement;//获得根节点 nodes = root.SelectNodes("descendant::Book[Name... 阅读全文
摘要:
protected void btnRead_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); ds.ReadXml(Server.MapPath("Employee.xml"));//读取XML文件 //GridView控件配置数据源 gvEmployee.DataSource = ds; gvEmployee.DataBind(); } protected void btnWrite_Click(object sender, Eve... 阅读全文
摘要:
using (Conn = new SqlConnection(ConnectionString)) { Conn.Open();//打开数据库连接 string sqlstr = "select * from UserInfo2;select * from UserOrder";//两条SQL语句 SqlCommand cmd = new SqlCommand(sqlstr, Conn); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.Close... 阅读全文
摘要:
DataAdapter批量插入数据using (Conn = new SqlConnection(ConnectionString)){ Conn.Open();//打开数据库连接 string sqlstr = "select * from UserInfo2"; SqlDataAdapter da = new SqlDataAdapter(); SqlCommand insertcmd = new SqlCommand(sqlstr, Conn);//创建Command实例 SqlCommandBuilder cb = new SqlCommandBuilder(da) 阅读全文
摘要:
using (Conn = new SqlConnection(ConnectionString)) { Conn.Open();//打开数据库连接 string sqlstr = "select * from UserInfo2"; SqlCommand cmd = new SqlCommand(sqlstr, Conn); cmd.CommandType = CommandType.Text; SqlDataReader dr = cmd.ExecuteReader(Comman... 阅读全文
摘要:
using (Conn = new SqlConnection(ConnectionString)) { //DataAdapter更新数据 Conn.Open();//打开数据库连接 string sqlstr = "select * from UserInfo2 where UserName = @UserName"; SqlDataAdapter da = new SqlDataAdapter(); SqlCommand updatecmd = new SqlCommand(s... 阅读全文
摘要:
using (Conn = new SqlConnection(ConnectionString)) { //DataAdapter插入数据 Conn.Open();//打开数据库连接 string sqlstr = "select * from UserInfo2"; SqlDataAdapter da = new SqlDataAdapter(); SqlCommand insertcmd = new SqlCommand(sqlstr, Conn); S... 阅读全文
摘要:
using (Conn = new SqlConnection(ConnectionString)) { //DataAdapter删除数据 Conn.Open();//打开数据库连接 string sqlstr = "select * from UserInfo2 where UserName = @UserName"; SqlDataAdapter da = new SqlDataAdapter(); SqlCommand deletecmd = new SqlCommand(s... 阅读全文
摘要:
protected SqlConnection Conn; protected string ConnectionString = "server=.; database=ExpatiateAspNet; uid=sa; pwd="; protected void Page_Load(object sender, EventArgs e) { using (Conn = new SqlConnection(ConnectionString)) { Conn.Open();//打开数据库连接 SqlComma... 阅读全文
摘要:
protected SqlConnection Conn; protected string ConnectionString = "server=.; database=ExpatiateAspNet; uid=sa; pwd="; protected void Page_Load(object sender, EventArgs e) { using (Conn = new SqlConnection(ConnectionString)) { Conn.Open();//打开数据库连接 SqlComma... 阅读全文
摘要:
没有为扩展名“.html”注册的生成提供程序。可以在 machine.config 或 web.config 中的 <compilation><buildProviders> 节注册一个。请确保所注册的提供程序具有包含值“Web”或“All”的 BuildProviderAppliesToAttribute 属性。说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。解决方法:增加一项web.config配置节点(红色部分为需新增节点):<compilation defaultLanguage 阅读全文