Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
UL Ext:执行 SQL SELECT 语句并以 ULResultSet 对象形式返回结果集。
Public Function ExecuteResultSet() As ULResultSet
public ULResultSet ExecuteResultSet()
ULResultSet 对象形式的结果集。
ULException 类 发生 SQL 错误。
InvalidOperationException 该命令处于无效状态。ULCommand.Connection 值缺失或关闭、ULCommand.Transaction 值与连接的当前事务状态不匹配,或者 ULCommand.CommandText 值无效。
该语句就是当前的 ULCommand 对象,它具有必需的 ULCommand.CommandText 和任何 ULCommand.Parameters 值。ULResultSet 对象为可编辑的结果集,您可在其上执行定位更新和删除。要获得完全可编辑的结果集,请使用 ULCommand.ExecuteTable 方法或 ULDataAdapter 对象。
如果 ULCommand.CommandType 值为 System.Data.CommandType.TableDirect,则 ExecuteReader 方法会执行 ULCommand.ExecuteTable 调用并返回一个转换为 ULResultSet 对象的 ULTable 对象。
此方法支持通过动态 SQL 进行的定位更新和删除。
cmd.CommandText = "SELECT id, season, price FROM OurProducts"; ULResultSet rs = cmd.ExecuteResultSet(); while( rs.Read() ) { string season = rs.GetString( 1 ); double price = rs.GetDouble( 2 ); if( season.Equals( "summer" ) ) { rs.UpdateBegin(); rs.SetDouble( 2, price * .5 ); rs.Update(); } if( season.Equals( "discontinued" ) ) { rs.Delete(); } } rs.Close();