Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (中文) » UltraLite - .NET 编程 » UltraLite .NET 2.0 API 参考 » ULConnection 类 » ExecuteTable 方法

 

ExecuteTable(String, String, CommandBehavior) 方法

UL Ext.: 以指定的命令行为检索数据库表以便直接进行操作。使用指定的索引打开(排序)该表。

语法
Visual Basic
Public Function ExecuteTable( _
   ByVal tableName As String, _
   ByVal indexName As String, _
   ByVal cmdBehavior As CommandBehavior _
) As ULTable
C#
public ULTable ExecuteTable(
   string  tableName,
   string  indexName,
   CommandBehavior cmdBehavior
);
参数
  • tableName   要打开的表的名称。

  • indexName   用于打开(排序)表的索引名称。

  • cmdBehavior   用于描述查询结果及其对连接影响的 System.Data.CommandBehavior 标志的逐位组合。UltraLite.NET 仅支持 System.Data.CommandBehavior.Default、System.Data.CommandBehavior.CloseConnection 和 System.Data.CommandBehavior.SchemaOnly 标志。

返回值

ULTable 对象形式的表。

注释

此方法为 ULCommand.ExecuteTable(System.Data.CommandBehavior) 的快捷方式,它不需要 ULCommand 实例。提供此方法是为了帮助用户从较早的 UltraLite.NET 版本进行移植(它替换了 iAnywhere.UltraLite.Connection.GetTable() 和 iAnywhere.UltraLite.Table.Open())。

示例

以下代码会使用名为 MyIndex 的索引打开名为 MyTable 的表。它假定已打开了一个名为 conn 的 ULConnection 实例。

' Visual Basic
Dim t As ULTable = conn.ExecuteTable( _
    "MyTable", "MyIndex", CommandBehavior.Default _
  )
' The line above is equivalent to
' Dim cmd As ULCommand = conn.CreateCommand()
' cmd.CommandText = "MyTable"
' cmd.IndexName = "MyIndex"
' cmd.CommandType = CommandType.TableDirect
' Dim t As ULTable = cmd.ExecuteTable(CommandBehavior.Default)
' cmd.Dispose()
// C#
ULTable t = conn.ExecuteTable(
    "MyTable", "MyIndex", CommandBehavior.Default
  );
// The line above is equivalent to
// ULTable t;
// using(ULCommand cmd = conn.CreateCommand())
// {
//     cmd.CommandText = "MyTable";
//     cmd.IndexName = "MyIndex";
//     cmd.CommandType = CommandType.TableDirect;
//     t = cmd.ExecuteTable(CommandBehavior.Default);
// }
另请参见