Examining a SQL Data Source

A SQL data source //数据源is not the same as a SQL data connection.  A data connection only has knowledge of//知道 the database to which it is connecting.  A SQLDataSource control uses a defined //定义了的data connection, and also encapsulates //内敛,装入胶囊,封进内部,压缩how a control will interact with //相互作用the database by allowing you to define the SELECT, INSERT, UPDATE, and DELETE SQL statements//语句,声明,陈述.

A SQLDataSource control was automatically created when you dragged the authors table onto the design surface //设计界面,而不是代码界面in the previous lesson//上一课中. 

1.  You will now redefine//重定义 the SELECT statement //select语句that was automatically set when you added the GridView control. Open the SqlDataSource Tasks//见下图漂浮的小窗口中的青灰色部分 menu and select Configure Data Source//配置数据源.

 

Notice that a pubsConnectionString1 connection string//连接字符串 has already been defined for you.  This resides //住,居留,属于in //放在your web.config file and was automatically added //自动加入by VWD when you dragged //拖the authors table //名称叫author的表onto the design surface//设计界面中, adding GridView and SqlDataSource controls. 

You can examine//检查 your web.config file and view //查看the XML that contains //包含these settings//设置.  This allows you to change your connection string //连接字符串without modifying your application.

The XML below is what you would find in your web.config file //web配置文件regarding //关心,注意,尊敬;视为,注意,和...有关this data connection//与数据连接相关:

<connectionStrings>
<add name="pubsConnectionString1" connectionString="Server=localhost\sqlexpress; InitialCatalog=pubs;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>

2.  Click Next to arrive at the Configure the Select Statement//配置select语句 <见下图中间偏上白色部分>step. Notice how you can modify which columns//列 are selected, add a WHERE clause//where<条件>分句, etc. You will do this in the next lesson.

3. If you have time, feel //感觉free to click the Next button and test the query//查询. Close the dialog by clicking Cancel.

 

posted on 2007-04-05 13:23  改变热爱  阅读(175)  评论(0)    收藏  举报

导航