资源预览内容
第1页 / 共25页
第2页 / 共25页
第3页 / 共25页
第4页 / 共25页
第5页 / 共25页
第6页 / 共25页
第7页 / 共25页
第8页 / 共25页
第9页 / 共25页
第10页 / 共25页
亲,该文档总共25页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
本文是中英对照毕业设计论文外文文献翻译,下载后无需调整复杂的格式直接可用!一辈子也就一次的事!文献引用作者出处信息: Diane_Zak,Database Queries with SQL Programming with Microsoft Visual Basi,2019:550-585 (如觉得年份太老,可改为近2年,毕竟很多毕业生都这样做)英文3526单词,20361字符(字符就是印刷符),中文5774汉字。(如果字数多了,可自行删减,大多数学校都是要求选取外文的一部分内容进行翻译的。)Database Queries with SQLFOCUS ON THE CONCEPTS LESSONConcepts covered in this lesson: F-1 SELECT statement F-2 Creating a query F-3 Parameter queries F-4 Saving a query F-5 Invoking a query from codeF-1 SELECT StatementThe most commonly used statement in Structured Query Language, or SQL, is the SELECT statement. You use the SELECT statement to create database queries. As you learned in Chapter 11, a database query, often referred to more simply as a query, is a statement that allows you to retrieve specific information from a database. For example, you can use a query to specify the fields and records you want either to display or to use in a calculation. The basic syntax of the SELECT statement is shown in Figure 12-1 along with some of the operators that can be included in the WHERE clauses condition. Capitalizing the boldfaced keywords in a SELECT statement is optional; however, many programmers do so for clarity.In the syntax, fieldList is one or more field names separated by commas, and table is the name of the table containing the fields. The WHERE and ORDER BYclauses are optional parts of the syntax. You use the WHERE clause, which contains a condition, to limit the records you want to retrieve. Similar to the condition in the If.Then.Else and Do.Loop statements, the condition in a WHERE clause specifies a requirement that must be met for a record to be selected. The ORDER BY clause is used to arrange the records in either ascending (the default) or descending order by one or more fields. Figure 12-2 shows examples of using the SELECT statement to query the Winners table in the Oscars.mdf database.Notice that the word Argo in Example 3 appears in single quotes, but the number 2014 in Example 2 does not. The single quotes around the value in the WHERE clauses condition are necessary only when you are comparing a field that contains text with a literal constant. The single quotes are not necessary when you are comparing a numeric field with a literal constant. Text comparisons in SQL are not case sensitive. Therefore, the WHERE clause in Example 3 can also be written as WHERE Pi c t ur e = a r go .In Example 4, the SELECT statements WHERE clause contains the SQL LIKE operator along with the % (percent sign) wildcard, which represents zero or more characters. The statement tells the computer to select the Year and Picture fields for records whose Picture field begins with the word “The”followed by a space and zero or more characters. The LIKE operator can also be used with the 2 (underscore) wildcard, which represents one character.The WHERE clause in Example 5s SELECT statement contains the OR operator. The clause tells the computer to select the specified fields for any record whose Year field contains either 2010 or 2015. The ORDER BYclause in the statement arranges the selected records in descending order by the Year field.F-2 Creating a QueryIn this section, you will use the Query Builder dialog box, which you learned about inChapter 11, to create queries for the examples shown in Figure 12-2. The queries will allow you to observe the way the SELECT statements in those examples retrieve the desired fields and records from the database.To create queries for the examples in Figure 12-2:1.Open the Oscars Solution.sln file contained in the VB2017Chap12Oscars Solution-SELECT folder. Open the designer and Solution Explorer windows. The Oscar Winners application is already connected to the Oscars.mdf database, and the OscarsDataSet is already created.2.Start the application. The OscarsDataSet contains the 10 records shown in Figure 12-3.3.Click the Exit button. Right-click OscarsDataSet.xsd in the Solution Explorer window. The .xsd file, called the datasets schema file, contains information about the tables, fields, records, and properties included in the OscarsDataSet. Click Open to open the DataSet Designer window. See Figure 12-4.4.Right-click WinnersTableAdapter in the DataSet Designer window. Point to Add on the shortcut menu and then click Query. (If Add does not appear on the shortcut menu, click Add Query instead.) Doing this starts the TableAdapter Query Configuration Wizard. The Use SQL statements radio button should be selected on the Choose a Command Type screen, as shown in Figure 12-5.5.Click the Next button to display the Choose a Query Type screen. Verify that the “SELECT which returns rows” radio button is selected.6.Click the Next button to display the Specify a SQL SELECT statement screen. The “What data should the table load?” box contains the default query, which selects all of the fields and records from the table. See Figure 12-6. The defau
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号