知识点小结
Posted 快乐的小银龙
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识点小结相关的知识,希望对你有一定的参考价值。
if (this.treeView1.SelectedNode.Level>0) { //判断TreeView选中节点是否为空 }
private void Form1_Load(object sender, EventArgs e) { //判断xml文件的属性值之经典代码 Streats str = new Streats(); TreeNode tn=null; XmlDocument doc = new XmlDocument(); doc.Load("Address.xml"); XmlNode root = doc.DocumentElement; string name = ""; foreach (XmlNode item in root.ChildNodes) { if (root.Attributes["name"].Value != name) { tn = new TreeNode(root.Attributes["name"].Value); str.StreesName = root.Attributes["name"].Value; list.Add(str); treeView1.Nodes.Add(tn); } TreeNode tree = new TreeNode(item.Attributes["name"].Value); str.JuweiHui = item.Attributes["name"].Value; foreach (XmlNode it in item.ChildNodes) { TreeNode xx = new TreeNode(it.Attributes["name"].Value); str.Smid = it.Attributes["name"].Value; tree.Nodes.Add(xx); foreach (XmlNode vv in it.ChildNodes) { TreeNode pp = new TreeNode(vv.InnerText); str.Fijname = vv.InnerText; pp.Tag = list; xx.Nodes.Add(pp); } } tree.Tag = item; tn.Nodes.Add(tree); name = root.Attributes["name"].Value; } }
什么是程序集
1.是一个或多个托管模块,以及一些资源文件的逻辑组合
2.是组件的复用,以及实施安全策略的版本的最小单位
3.包含一个或者多个类型自定义文件盒资源文件的集合
//01.查询所有年级信息 public List<Grade> getAllGrades() { string sql = "select * from grade"; DataTable dt = SQLHelper.ExecuteDataTable(sql); MyTool tool=new MyTool(); List<Grade> list = tool.DataTableToList<Grade>(dt); return list; }
你给我一个sql我还你个table
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Student.Model; using System.Data; namespace Student.DAL { public class StudentDAL { public bool AddStudent(Students stu) { bool falg = false; string sql = @"Insert into Student(Student,LoginPwd,StudentName,Gender,GradeId,Phone,Address,Birthday,Email) values ("+stu.StudentNo+",\'"+stu.LoginPwd+"\',\'"+stu.StudentName+"\',\'"+stu.Gender+"\',"+stu.GradeId+",\'"+stu.Phone+"\',\'"+stu.Address+"\',\'"+stu.Birthday+"\',\'"+stu.Email+"\',)"; int a= SQLHelper.ExecuteNonQuery(sql); if (a>1) { falg = true; } return falg; } public List<Grade> StudentList() {
//弱类型的DataTable转换成钱类型List<>泛型集合 string sql = "select *from Grade"; DataTable dt = SQLHelper.ExecuteDataTable(sql); MyTool tool = new MyTool(); return tool.DataTableToList<Grade>(dt); } } }
create procedure Usp_S2227GetInitial @gender char(1), @sum int Output --输出参数 as select *from Student where Gender=@gender select @sum=COUNT(1) from Student where Gender=@gender return 100 declare @num int set @num=0 declare @myReturn int set @myReturn=0 exec @myReturn=Usp_S2227GetInitial \'1\',@num Output print @myReturn
<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> <connectionStrings> <add name="contr" connectionString="Data Source=.; Initial CataLog=MySchool;Uid=Sa;"/> </connectionStrings> </configuration> <!-- App.config配置文件-->
//Sql注入恒等式 \' or 1=1 --
drop Student where studentid>4
public static string Constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString; public static int id;
using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; namespace D_018 { public class MyTool { public void GetStudentInsterEx(Student stu) { string str = "Data Source=.; Initial CataLog=MySchool; Uis=Sa;"; string sql = "select *from Student where Student=@Student and StudentPwd=@StudentPwd"; string sql1 = "usp_GetS2227"; //自动释放连接对象 using (SqlConnection con = new SqlConnection(str)) { SqlCommand cmd = new SqlCommand(sql, con); //简易版防注入添加 cmd.Parameters.Add(new SqlParameter("@StudentName", stu.StudentName)); con.Open(); //创建事务 SqlTransaction tx = new SqlTransaction(); //绑定的到执行操作 cmd.Transaction = tx; //指定事务类型 cmd.CommandType = CommandType.StoredProcedure; SqlParameter[] p = { //@...要与数据库里面的事务字段一一对应 //要求 //1.带输入参数的储存过程 性别 char(1) //2.带输出参数的储存过程 统计女生的总人数 @sum //3.带返回值的储存过程 输出储存过程的返回值 new SqlParameter("@gender","1"), new SqlParameter("@num",SqlDbType.Int), new SqlParameter("myRetuen",SqlDbType.Int) }; //把值绑定到TextBox中 //表示为输出参数 p[1].Direction = ParameterDirection.InputOutput;
//设置参数为返回值类型
p[2].Direction = ParameterDirection.ReturnValue;
//加入到cmd对象中
cmd.Parameters.AddRange(p); int count = Convert.ToInt32(p[1].Value); int ret = Convert.ToInt32(p[2].Value); //开启事务 tx = con.BeginTransaction(); //提交事务 tx.Commit(); } } } }
using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; namespace D_018 { public class MyTool { public void GetStudentInsterEx(Student stu) { string str = "Data Source=.; Initial CataLog=MySchool; Uis=Sa;"; string sql = "select *from Student where Student=@Student and StudentPwd=@StudentPwd"; string sql1 = "usp_GetS2227"; //自动释放连接对象 using (SqlConnection con = new SqlConnection(str)) { SqlCommand cmd = new SqlCommand(sql, con); //简易版防注入添加 cmd.Parameters.Add(new SqlParameter("@StudentName", stu.StudentName)); con.Open(); //创建事务 //开启事务 SqlTransaction tx = con.BeginTransaction(); //绑定的到执行操作 cmd.Transaction = tx; //指定储存过程类型 cmd.CommandType = CommandType.StoredProcedure; SqlParameter[] p = { //@...要与数据库里面的事务字段一一对应 //要求 //1.带输入参数的储存过程 性别 char(1) //2.带输出参数的储存过程 统计女生的总人数 @sum //3.带返回值的储存过程 输出储存过程的返回值 new SqlParameter("@gender","1"), new SqlParameter("@num",SqlDbType.Int), new SqlParameter("myRetuen",SqlDbType.Int) }; //把值绑定到TextBox中 //表示为输出参数 p[1].Direction = ParameterDirection.InputOutput; //设置参数为返回值类型 p[2].Direction = ParameterDirection.ReturnValue; //加入到cmd对象中 cmd.Parameters.AddRange(p); int count = Convert.ToInt32(p[1].Value); int ret = Convert.ToInt32(p[2].Value); //提交事务 tx.Commit(); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; namespace MySchool.BLL { //(util)通用工具类 public class MySchoolBLL { //MD5加密 public string MD5GetEx(string name) { MD5CryptoServiceProvider m = new MD5CryptoServiceProvider(); byte[] b1 = Encoding.Default.GetBytes(name); byte[] b2 = m.ComputeHash(b1); string na = string.Empty; foreach (byte item in b2) { na += item.ToString("x2"); } return na; } //加密不可逆 //可以对字符串/文件加密 } }
MD5 m = new MD5CryptoServiceProvider(); byte[] a = Encoding.Default.GetBytes("1"); byte[] b=m.ComputeHash(a); StringBuilder sb = new StringBuilder(); foreach (byte item in b) { sb.Append(item.ToString("X2")); } Console.WriteLine(sb.ToString()); Console.ReadKey();
//删除光标消失 int xx = dataGridView1.CurrentRow.Index; dataGridView1.Rows[xx].Selected = true; dataGridView1.Rows[0].Selected = false;
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="file/jQuery1.11.1.js" type="text/javascript"></script> </head> <script> $(document).ready(function(){ var str="www.bdqn"; str.title="北大青鸟"; alert(str.substring (4)); }); </script> <body> </body> </html>
select *from Room select *from RoomType select *from RoomState select RoomID,BedNUm,RoomStateName,TypeName,Description ,GuestNum,TypeID from RoomType,Room,RoomState where Room.RoomStateID=RoomState.RoomStateID and RoomTypeID=RoomType.TypeID insert into Room(BedNum,RoomStateID,RoomTypeID,Description,GuestNum) values(10,2,13,\'ing送的\',0) update Room set BedNum=20,RoomTypeID=19,Description=\'ing房子\' where RoomID=26 select RoomID, Convert(varchar(2),RoomID)+ \'号房(床位:\' +Convert(varchar(2),(BedNum-GuestNum)) + cast(\')\' as varchar(20)) as description from Room where BedNUm>GuestNum delete Room where RoomID=26 select *from ResideState select *from GuestRecord delete GuestRecord where GuestID=8 insert into GuestRecord(IdentityID,GuestName,RoomID,ResideID,ResideDate,Deposit) values (112313123,\'灰太狼\',6,1,\'2012-2-3\',2000) update Room set GuestNum+=1 where RoomID=6 select GuestName,Identityid,ResideDate,Deposit,ResideName,LeaveDate,TotalMoney,Room.RoomID,TypeName,RoomStateName,GuestId from RoomType,Room,GuestRecord,RoomState,ResideState where RoomType.TypeID=Room.RoomTypeID and RoomState.RoomStateID=Room.RoomStateID and Room.RoomID=GuestRecord.RoomID and ResideState.ResideId=GuestRecord.ResideID and ResideDate between Convert(datetime,\'2011-02-12 16:50:00.000\') and Convert(datetime,\'2013-09-01 10:47:00.000\') and GuestRecord.ResideID=1 select RoomId from Room where RoomTypeID=13 SELECT a.RoomID, a.BedNum, a.RoomStateID, a.Description, a.GuestNum, a.RoomTypeID, b.TypeName, b.TypePrice, c.RoomStateName FROM [Room] a INNER JOIN [RoomType] b ON a.RoomTypeID = b.TypeID INNER JOIN [RoomState] c ON a.RoomStateID = c.RoomStateID WHERE 1=1
表示层exe 业务逻辑层dll 数据访问层dll
E:\\apache-tomcat-7.0.77\\work\\Catalina\\localhost\\AA\\org\\apache\\jsp
/* * Generated by the Jasper component of Apache Tomcat * Version: Apache Tomcat/7.0.77 * Generated at: 2017-07-20 02:28:50 UTC * Note: The last modified time of this file was set to * the last modified time of the source file after * generation to assist with modification tracking. */ package org.apache.jsp; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; import java.util.*; public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase implements org.apache.jasper.runtime.JspSourceDependent { private static final javax.servlet.jsp.JspFactory _jspxFactory = javax.servlet.jsp.JspFactory.getDefaultFactory(); private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants; private volatile javax.el.ExpressionFactory _el_expressionfactory; private volatile org.apache.tomcat.InstanceManager _jsp_instancemanager; public java.util.Map<java.lang.String,java.lang.Long> getDependants() { return _jspx_dependants; } public javax.el.ExpressionFactory _jsp_getExpressionFactory() { if (_el_expressionfactory == null) { synchronized (this) { if (_el_expressionfactory == null) { _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory(); } } } return _el_expressionfactory; } public org.apache.tomcat.InstanceManager _jsp_getInstanceManager() { if (_jsp_instancemanager == null) { synchronized (this) { if (_jsp_instancemanager == null) { _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig()); } } } return _jsp_instancemanager; } public void _jspInit() { } public void _jspDestroy() { } public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException { final javax.servlet.jsp.PageContext pageContext; javax.servlet.http.HttpSession session = null; final javax.servlet.ServletContext application; final javax.servlet.ServletConfig config; javax.servlet.jsp.JspWriter out = null; final java.lang.Object page = this; javax.servlet.jsp.JspWriter _jspx_out = null; javax.servlet.jsp.PageContext _jspx_page_context = null; try { response.setContentType("text/html;charset=utf-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write(\'\\r\'); out.write(\'\\n\'); String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; out.write("\\r\\n"); out.write("\\r\\n"); out.write("<!DOCTYPE HTML PUBLIC \\"-//W3C//DTD HTML 4.01 Transitional//EN\\">\\r\\n"); out.write("<html>\\r\\n"); out.write(" <head>\\r\\n"); out.write(" <base href=\\""); out.print(basePath); out.write("\\">\\r\\n"); out.write(" \\r\\n"); out.write(" <title>My JSP \'index.jsp\' starting page</title>\\r\\n"); out.write("\\t<meta http-equiv=\\"pragma\\" content=\\"no-cache\\">\\r\\n"); out.write("\\t<meta http-equiv=\\"cache-control\\" content=\\"no-cache\\">\\r\\n"); out.write("\\t<meta http-equiv=\\"expires\\" content=\\"0\\"> \\r\\n"); out.write("\\t<meta http-equiv=\\"keywords\\" content=\\"keyword1,keyword2,keyword3\\">\\r\\n"); out.write("\\t<meta http-equiv=\\"description\\" content=\\"This is my page\\">\\r\\n"); out.write("\\t<!--\\r\\n"); out.write("\\t<link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"styles.css\\">\\r\\n"); out.write("\\t-->\\r\\n"); out.write(" </head>\\r\\n"); out.write(" \\r\\n"); out.write(" <body>\\r\\n"); out.write(" 今天天气不错\\r\\n"); out.write(" "); String info= request.getRemoteAddr()+ "\\t"+request.getRemoteUser(); System.out.println(info); out.write("\\r\\n"); out.write(" </body>\\r\\n"); out.write("</html>\\r\\n"); } catch (java.lang.Throwable t) { if (!(t instanceof javax.servlet.jsp.SkipPageException)){ out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { if (response.isCommitted()) { out.flush(); } else { out.clearBuffer(); } } catch (java.io.IOException e) {} if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); else throw new ServletException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } } }
<% String info= request.getRemoteAddr()+ "\\t"+request.getRemoteUser(); System.out.println(info); %>
<% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>
1.什么内置对象 不用new 直接用 2.request.setResuqestDisponse().forname()转向 request.getParamper();获取属性 resquest.setAttbrite()设置属性 resquest.getParamperValues(); 3.response.sendRedrist();重定向 4 转发 重定向 请求次数 1 2 url地址 不变 变 站内站外 站内 站外 资源共享 共享 不共享 5.保存在服务器端的一次请求N次相应的过程 6.session.setAttbrite("name",name); 7.<%@ page import="java.util.*" lanauge="html/text" pageEncoding="utf-8" %> 8小脚本 注释 表达式
在我们在myeclips里使用junit测试工具时有时会遇到错误,这是什么原因呢? 导致问题的原因通常有下面几个: (1)没有导入jar包 (2)导入jar包版本太低 (3)注意@Test要写在方法上面
即使报错 但是 Test单词只要变成灰色就能用因为你还没有写测试方法
jsp 页面 500报错 该 大写的 UTF-8 localhost
<!--声明出去的是全局变量 <以上是关于知识点小结的主要内容,如果未能解决你的问题,请参考以下文章