从存储过程数据集的表名 [英] DataSet's Table name from a Stored Procedure
问题描述
我使用的是存储过程来填充DataSet。我需要做的就是强制填充时所创建的数据表的名称。有从存储过程返回多个表。最后一个表是一个我需要确保有一个特定的名字时返回。它是通过返回一个变量的值,以及从任何表不拉创建
I am using a stored procedure to fill a DataSet. What I need to do is force the name of the DataTable that is created when filled. There are multiple tables returned from the Stored Procedure. The last table is the one I need to make sure has a specific name when returned. It is created by returning a value of a variable and not pulling from any tables.
选择@Phone为My_800Number
SELECT @Phone as My_800Number
我怎样才能让这个返回的表称为D1Header?
How can I make this return as table called "D1Header"?
推荐答案
有没有ADO.NET原生的方式来做到这一点; ADO.Net具有顺序号分配一个生成的名称,根据这个
There is no ADO.NET Native way to do it; ADO.Net assign a generated name with a sequence number, according to this
您可以临时解决它......如果你说你需要的最后一个表与一个特定的名称,你可以这样做:
You can workaround it... if you say you need the last table with a specific name, you can do:
if (ds.Tables.Count > 0) {
ds.Tables[ds.Tables.Count - 1].TableName = "name";
}
这篇关于从存储过程数据集的表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!