Visual Studio .NET如何为并发控制生成SQL语句
来源:56doc.com 资料编号:5D2736 资料等级:★★★★★ %E8%B5%84%E6%96%99%E7%BC%96%E5%8F%B7%EF%BC%9A5D2736
资料介绍
英文原文 Visual Studio .NET Technical Articles How Visual Studio .NET Generates SQL Statements for Concurrency Control Steve Stein Visual Studio Team Microsoft Corporation February 2002 Summary: This paper examines the SQL statements Visual Studio® .NET generates for different kinds of concurrency control, how to modify them for better performance, and how to generate a statement that does not use concurrency control. (5 printed pages) Contents Introduction Prerequisites Where Are the SQL Statements? Concurrency and Data Adapters Optimizing the Generated SQL Statement Concurrency and Command-Builder Objects Conclusion Introduction Any application that might have multiple users simultaneously attempting to access and modify data needs some form of concurrency control. Otherwise, one user's changes could inadvertently overwrite modifications from other users. The design tools in Visual Studio .NET can create SQL statements that use the "check all values" approach to optimistic concurrency or the "last-in wins" approach to updating data. This paper will explain: • How each of these statement types are generated. • How to modify the generated SQL statement for better performance. Prerequisites You should have an understanding of: • Fundamental ADO.NET data concepts, including datasets and data adapters. For more information, see Introduction to Data Access with ADO.NET. • Concurrency control basics and the options available in Visual Studio .NET. For more information, see Introduction to Data Concurrency in ADO.NET. Where Are the SQL Statements? SQL statements are located in the CommandText property of command objects. SQL commands are automatically generated at design time when configuring data adapters, and at run time when using command builder objects. For more information, see Concurrency and Command Builder Objects. Configuring Data Adapters • Drag a data adapter from the Data tab of the Toolbox • Drag a table from Server Explorer • Modifying an existing adapter, by selecting a data adapter and clicking the Configure Data Adapter link at the bottom of the Properties window. Command Builder objects • Command builder objects are created programmatically at run time. For more information, see (SqlCommandBuilder or OleDbCommandBuilder) Concurrency and Data Adapters When configuring data adapters with the Data Adapter Configuration Wizard, you can decide whether to use optimistic concurrency for the generated Update and Delete statements. 英文翻译 Visual Studio .NET如何为并发控制生成SQL语句 翻译:翟靖轩 原作者:Steve Stein Visual Studio Team Microsoft Corporation 2002年2月 摘要:这篇文章研究Visual Studio® .NET为不同的并发控制方式所产生的SQL语句,如何对它们进行修改可以提高执行效率,以及如何生成不带并发控制的SQL语句。 目录 引言 阅读此文章时应具备的一些知识 生成的SQL语句在哪里 并发与数据适配器(DataAdapter) 优化生成的SQL语句 并发与CommandBuilder对象 结论 引言 任何可能同时被多个用户访问或修改数据的应用程序,都需要进行并发控制。否则,一个用户更改记录时可能不经意的覆盖了其他用户的更改。Visual Studio .NET的设计工具可以生成“保持所有值”方式的开放式并发SQL语句或生成“最后的更新生效”方式的SQL语句来更新数据。这篇文章将解释: 不同的SQL语句是如何生成的 如何修改自动生成的SQL语句可以提高执行效率 阅读此文章时应具备的一些知识 你需要具备以下知识: 基本的ADO.NET概念,包括数据集(DataSet)以及数据适配器(DataAdapters)。更多信息请参见ADO.NET 数据访问介绍(Introduction to Data Access with ADO.NET)。 数据并发机制以及会操作Visual Studio .NET。更多内容请参见 介绍 ADO.NET 中的数据并发(Introduction to Data Concurrency in ADO.NET)。 自动生成的SQL语句在哪里 自动生成的SQL语句在command对象的CommandText属性里。在设计阶段配置DataAdapter对象时或使用CommandBuilder对象时SQL命令被自动生成。更多信息,请参见 并发与CommandBuilder对象(Concurrency and Command Builder Objects)。 配置DataAdapter对象 从工具箱的数据选项卡中拖一个DataAdapter对象 从服务器资源管理器拖一个数据表 选中已有的DataAdapter对象,然后单击在属性窗口底部的“配置数据适配器”链接 CommandBuilder对象 CommandBuilder对象在运行时刻被创建,更多信息请参阅 SqlCommandBuilder 或 OleDbCommandBuilder。 并发控制与数据适配器(DataAdapter) 使用“数据适配器配置向导”配置数据适配器时,你可以选择是否使用开放式并发来生成Update和Delete语句。 |