2

我知道在 .net 数据集中,您可以为表命名。在您取回数据之前,是否可以从 Sql 中执行此操作。

我的问题是,我有一个存储过程,它根据输入参数返回 2 个或 4 个表,所以我有一个 If 语句

' Verify that the expected results of two tables were return from the Stored Procedure
If (dsPosting.Tables.Count = 4 AndAlso intBankType <> 10) _
OrElse (dsPosting.Tables.Count = 2 AndAlso intBankType = 10) Then

现在 Stored Procedure 变成了 2 或 5 并且顺序不同了。有没有更好的方法来识别我想要“这两个表”,而不是在代码中硬编码值并不得不发布新版本。

理想情况下,我想要类似ds.Table("TheOneIWant")或类似的东西?

4

1 回答 1

1

The successive separate result in TDS do not have names; they are just sequential grids of results. So no, there is no way to do this. Your code needs to know (or be able to deduce) what results it is expecting. One option might be to look at the schema of each as it comes back.

Another way of looking at this is to look at the line:

Now the Stored Procedure has changed to 2 or 5 and the order is different.

That is a breaking change; avoiding breaking changes is a really good idea.

于 2013-06-05T13:51:11.567 回答