- 1、本文档共39页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
[电脑基础知识]Week - 14 LAB Database
SQL Server Display Data in Gridview Display Data in Gridview using System.Configuration; using System.Data.SqlClient; using System.Data; protected void Page_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection (ConfigurationManager.ConnectionStrings [bankConnectionString1].ConnectionString); con.Open(); SqlCommand cmd = new SqlCommand(“select * from student, con); cmd.CommandType = CommandType.Text; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataSet ds = new DataSet(); da.Fill(ds, student); this.GridViewDemo.DataSource = ds; this.GridViewDemo.DataBind(); } 4.7 Views A View is a Virtual Table. It is not like a simple table, but is a virtual table which contains columns and data from different tables (may be one or more tables). A View does not contain any data, it is a set of queries that are applied to one or more tables that is stored within the database as an object. Use of a View Views are used as security mechanisms in databases. Because it restricts the user from viewing certain column and rows. Views display only those data which are mentioned in the query, so it shows only data which is returned by the query that is defined at the time of creation of the View. The rest of the data is totally abstract from the end user. Creating a View CREATE VIEW SampleView As SELECT EmpID, EmpName FROM EmpInfo Create a View Display Data by Using View Display data by a View Work with Student Table Create a View and Display Data select * from student Create a View create view ViewStudent as select * from student; Run the View to see data select * from ViewStudent Select * from ViewStudent where SID = ‘s004’ Insert and Update Data in View select * from ViewStudent Insert Record into View insert into ViewStudent values (S006,SKS,India); Display the inserted data view select * from ViewStudent Update the View update ViewStudent SET Name = Sunny where SID = S006‘ Display the updated view select * from ViewStudent Differ
文档评论(0)