正在加载图片...
实验六使用NET数据提供程序访问数 据库 实验目的 1、掌握使用、NET对象访问数据库的步骤 2、掌握 Connection对象、 Command对象、 DataReader对象的使 用方法 实验内容 (1)创建并打开与 SQL Server70或更高版本的数据库的连接。连 接 SQL Server数据库 Student DB。在 Label控件中显示连接字 符串和打开、关闭当前数据库的连接状态。 ①设计页面。新建一个 ASPNET网站,向页面中添加一个 Label控 件 ②在 web. config文件中添加连接字符串。按照如图10-2所示中的代 码,在 web. config文件中添加连接字符串。 <add name="Student DB Connection String" connection String="Data Source=teacher: Initial Catalog=Student DB; Integrated Security=True"/> onnection Strings> ③编写事件代码。 在命名空间区域中添加如下内容: using System. Data using System. Data SqlClient; using System Configuration实验六 使用.NET 数据提供程序访问数 据库 实验目的 1、 掌握使用.NET 对象访问数据库的步骤。 2、 掌握 Connection 对象、Command 对象、DataReader 对象的使 用方法。 实验内容 (1) 创建并打开与 SQL Server 7.0 或更高版本的数据库的连接。连 接 SQL Server 数据库 StudentDB。在 Label 控件中显示连接字 符串和打开、关闭当前数据库的连接状态。 ① 设计页面。新建一个 ASP.NET 网站,向页面中添加一个 Label 控 件。 ② 在 web.config 文件中添加连接字符串。按照如图 10-2 所示中的代 码,在 web.config 文件中添加连接字符串。 <connectionStrings> <add name="StudentDBConnectionString" connectionString="Data Source=teacher; Initial Catalog=StudentDB; Integrated Security=True"/> </connectionStrings> ③ 编写事件代码。 在命名空间区域中添加如下内容: using System.Data; using System.Data.SqlClient; using System.Configuration;
向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有