Comparison of two modes of data access

xiaoxiao2021-04-04  247

ASP.NET 2.0 expands the mode of data accesses in ASP.NET1.1, and has two modes.

1. Use data source control (SqlDataSource / ObjectDataSource)

1) Create a project Twomode

2) Establish a database connection

Since ASP.NET 2.0 provides an app_data directory, you can copy the database file directly to this directory, and then in the Solution Explorer, you can see the file, as shown below Switch to "Database View", you can see the database, as shown

But in use, sometimes, when you use a new database file * .mdf to the app_code directory, the connection timeout will appear because the system will access the database for the first time, in addition to the necessary verification In addition to the information, you also need to generate a database log file, so you just expand the database file again. 3) Connect the database to drag and drop the data source control (for easy explanation, here using the SqlDataSource Control) to DEFAULT.ASPX Click the Configure Data Source on the right side of the Intelligent Induction, and the Database Connection Configuration Wizard is here, the system will identify The database in the app_data directory, if you don't place the database under app_data, then you will connect it yourself and save the database connection in Web.config Next, select the database Qian, you can test the results of the run, A GridView control is placed on the Default, setting the data source to SQLDataSource1, you can use "Auto Format" to set its style (2) to use the data set and the data adapter. This mode is simpler. Next introduction

转载请注明原文地址:https://www.9cbs.com/read-131794.html

New Post(0)