数据库实验报告
作者 : 卿笃军 原文地址:http://blog.csdn.net/qingdujun/article/details/29028363 使用SQL Server 开发服务器端应用程序 一、实验类别 综合型实验 二、实验目的 熟练掌握后台服务器端应用程序的开发。 三、实验环境 SQL Server 系列的数据库管理系统 四
作者 : 卿笃军
原文地址:http://blog.csdn.net/qingdujun/article/details/29028363
使用SQL Server 开发服务器端应用程序 一、实验类别综合型实验
二、实验目的
熟练掌握后台服务器端应用程序的开发。
三、实验环境
SQL Server 系列的数据库管理系统
四、实验内容
对学生-课程数据库,编写存储过程,完成下面功能:
1.逐条(使用游标)浏览某个系的学生记录;
2.统计任意一门课程的成绩分布情况,即按照各分数段统计人数;
3.统计每个学生的平均成绩及排名;
4.将学生选课成绩从百分制改为等级制(即A、B、C、D、E)显示。
五、实验要求
提交源程序并标识必要的注释。保证程序能正确编译和运行,认真撰写实验报告。
六、实验过程
1.创建数据库及数据表……具体代码及创建后的结果如下图1 所示。
注:以下的3 个表,全部是可视化创建,表初始化内容如下(仿照课本输入的数值),关系
的主码加下划线表示。
学生表:Student(Sno,Sname,Ssex,Sage,Sdept)
课程表:Course(Cno,Cname,Ccredit)
学生课程表:SC(Sno,Cno,Grade)
2.创建存储过程1 完成……功能,具体代码及运行结果如下图R1 所示。
具体代码1:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|

图:R1
3.创建存储过程2 完成……功能,具体代码及运行结果如下图R2 所示。
具体代码2:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|

图:R2
4.创建存储过程3 完成……功能,具体代码及运行结果如下图R3 所示。
具体代码3:
1 2 3 4 5 6 7 8 9 10 11 12 |
|

图:R3
5.创建存储过程4 完成……功能,具体代码及运行结果如下图R4 所示
具体代码4:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|

图:R4
七、实验总结
这2 周来,一直忙忙碌碌于各种事物,数据库作业一直拖到今天早上才开始写。按照作业要求,踏踏实实,一步一步的,将功能全部实现了。功能实现期间,查阅了不少互联网资料,当然课本也来来回回的翻阅了好几遍,没办法,自己实在是弱的可以。期间,主要查阅的关键字SQL ,CASE, WHEN, AVG 当然还有游标。完成期间,主要遇到的问题主要是以下几个:
存储结构1:Print 不显示任何东西
解决:原来是我游标说明处的SELECT 语句写错了。
错误:
1 2 |
|
1 2 |
|
主要学习到的内容:(注:以下参考eshizhan的博客园)
CASE 主要有2种表达形式
1)简单CASE函数:
1 2 3 4 |
|
1 2 3 4 |
|
由于我想显示姓名,学号,平均分,于是以下代码就出现了:
1 |
|
解决方法:
于是我分组的时候,将其全部包含进去了,机智啊。
1 |
|
设想与建议:其实,如果有时间,我想做一个界面版的查询~~~还是时间紧得很啊!!!只能等到课设的时候了。另外就是,由于我电脑上面安装的是wps,为了避免用office打开的时候,格式改变影响阅读,我将文档导成.pdf格式,便于阅读。
本报告SQL Server数据库下载:http://pan.baidu.com/s/1gdABS4N 密码:14io

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

How to implement HTTP streaming in C++? Create an SSL stream socket using Boost.Asio and the asiohttps client library. Connect to the server and send an HTTP request. Receive HTTP response headers and print them. Receives the HTTP response body and prints it.

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

Through the Go standard library database/sql package, you can connect to remote databases such as MySQL, PostgreSQL or SQLite: create a connection string containing database connection information. Use the sql.Open() function to open a database connection. Perform database operations such as SQL queries and insert operations. Use defer to close the database connection to release resources.

JSON data can be saved into a MySQL database by using the gjson library or the json.Unmarshal function. The gjson library provides convenience methods to parse JSON fields, and the json.Unmarshal function requires a target type pointer to unmarshal JSON data. Both methods require preparing SQL statements and performing insert operations to persist the data into the database.

Use the DataAccessObjects (DAO) library in C++ to connect and operate the database, including establishing database connections, executing SQL queries, inserting new records and updating existing records. The specific steps are: 1. Include necessary library statements; 2. Open the database file; 3. Create a Recordset object to execute SQL queries or manipulate data; 4. Traverse the results or update records according to specific needs.
