随笔分类 -  ADO.NET

摘要://在session状态中保存数据库数据 DataView dvMovies; dvMovies = (DataView)Session["Movies"]; if (dvMovies==null) { string constring = "Data Source=.;Initial Catalog=BalloonShop;Integrated Security=True"; SqlDataAdapter dad = new SqlDataAd... 阅读全文
posted @ 2013-02-18 10:46 yellowshorts 阅读(212) 评论(0) 推荐(0)
摘要:var MyConnectionString = @"Data Source=.;Initial Catalog=BalloonShop;Integrated Security=True"; using (SqlConnection Myconnection = new SqlConnection(MyConnectionString)) { Myconnection.StatisticsEnabled = true;//启用信息收集 var MySql = "select * from Category"; v... 阅读全文
posted @ 2013-02-17 17:38 yellowshorts 阅读(185) 评论(0) 推荐(0)
摘要:数据生成树使用存储过程在数据表中生成树数据库 Category1表结构________________________________________CREATE TABLE [dbo].[Category1]( [id] [int] IDENTITY(1,1) NOT NULL, [pid] [int] NULL, [Name] [varchar](100) NULL, [path] [varchar](255) NULL, [sort] [varchar](255) NULL, [isHot] [bit] NULL, [keywords] [text] NULL, [description 阅读全文
posted @ 2013-02-17 17:09 yellowshorts 阅读(241) 评论(0) 推荐(0)
摘要:var MyNumber = 123056.78; string[] MyScale = { "分", "角", "元", "拾", "伯", "仟", "万", "拾", "伯", "仟", "亿", "拾", "伯", "仟", "兆", "拾", "伯" 阅读全文
posted @ 2013-02-17 10:11 yellowshorts 阅读(251) 评论(0) 推荐(1)
摘要:1. 打开新的窗口并传送参数传送参数:response.write("<script>window.open('*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"')</script>")接收参数:string a = Request.QueryString("id");string b = Request.QueryString("id1");2.为按钮添加对话框 Button1.At 阅读全文
posted @ 2013-02-02 09:39 yellowshorts 阅读(181) 评论(0) 推荐(0)
摘要://创建XmlWriter实例 using (XmlWriter xw = XmlWriter.Create(Server.MapPath("user.xml"))) { xw.WriteComment("图书信息");//注释语句 //根节点开始 xw.WriteStartElement("Info"); //定义子节点Record xw.WriteStartElement("Record"); xw.WriteAttributeString(... 阅读全文
posted @ 2013-01-21 11:12 yellowshorts 阅读(188) 评论(0) 推荐(0)
摘要://创建XmlReader实例 using (XmlReader xr = XmlReader.Create(Server.MapPath("info.xml"))) { while (xr.Read()) { //根据节点类型输出内容 switch (xr.NodeType) { case XmlNodeType.Element://节点开始符号及其属性 Response.Write(... 阅读全文
posted @ 2013-01-21 11:09 yellowshorts 阅读(176) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2013-01-21 11:04 yellowshorts 阅读(126) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2013-01-21 10:46 yellowshorts 阅读(198) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2013-01-21 10:36 yellowshorts 阅读(157) 评论(0) 推荐(0)
摘要: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) 阅读全文
posted @ 2013-01-21 10:32 yellowshorts 阅读(310) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2013-01-21 10:16 yellowshorts 阅读(117) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2013-01-21 10:14 yellowshorts 阅读(258) 评论(0) 推荐(0)
摘要:using (Conn = new SqlConnection(ConnectionString)) { //DataAdapter插入数据 Conn.Open();//打开数据库连接 string sqlstr = "select * from UserInfo2"; SqlDataAdapter da = new SqlDataAdapter(); SqlCommand insertcmd = new SqlCommand(sqlstr, Conn); S... 阅读全文
posted @ 2013-01-21 10:13 yellowshorts 阅读(468) 评论(0) 推荐(1)
摘要: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... 阅读全文
posted @ 2013-01-21 10:11 yellowshorts 阅读(170) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2013-01-21 09:50 yellowshorts 阅读(211) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2013-01-21 09:45 yellowshorts 阅读(585) 评论(0) 推荐(0)