如何从数据集中的存储过程返回表名
我使用一个数据集来存储加载时需要的 15 个表。当我使用存储过程填充所有表时,它返回所有表,但表的名称并不与数据库中的实际表名称相同。
它采用表名称为 Table1、Table2、Table3 的所有表...
我希望它们的名称与表中实际的名称相同。
SELECT PK_GUEST_TYPE, [DESCRIPTION] FROM L_GUEST_TYPE
SELECT PK_AGE_GROUP_ID, AGE_GROUP FROM L_AGE_GROUP
SELECT PK_COMPANY_ID, COMPANY_NAME FROM M_COMPANY
SELECT PK_COUNTRY_ID, COUNTRY FROM L_COUNTRY
SELECT PK_EYE_COLOR_ID, [DESCRIPTION] FROM L_EYE_COLOR
SELECT PK_GENDER_ID, [DESCRIPTION] FROM L_GENDER
SELECT PK_HAIR_COLOR_ID, [DESCRIPTION] FROM L_HAIR_COLOR
SELECT PK_STATE_PROVONCE_ID, [DESCRIPTION] FROM L_STATE_PROVINCE
SELECT PK_STATUS_ID, [DESCRIPTION] FROM L_STATUS
SELECT PK_TITLE_ID, [DESCRIPTION] FROM L_TITLE
SELECT PK_TOWER_ID, [DESCRIPTION] FROM M_TOWER
SELECT PK_CITY_ID, [DESCRIPTION] FROM L_CITY
SELECT PK_REGISTER_TYPE_ID, [DESCRIPTION] FROM L_REGISTER_TYPE
这是我用于填充数据集的前端编码。
OpenConnection();
adp.Fill(ds);
CloseConnection(true);
I used a dataset to store 15 tables that I need at the time of loading. When i filled all the tables using stored procedure it returns me all the table but name of the table doesn't comes as that of actual table name in a database.
It takes all the table with table name as Table1, Table2, Table3...
I want them to be with the name as they actually are in table.
SELECT PK_GUEST_TYPE, [DESCRIPTION] FROM L_GUEST_TYPE
SELECT PK_AGE_GROUP_ID, AGE_GROUP FROM L_AGE_GROUP
SELECT PK_COMPANY_ID, COMPANY_NAME FROM M_COMPANY
SELECT PK_COUNTRY_ID, COUNTRY FROM L_COUNTRY
SELECT PK_EYE_COLOR_ID, [DESCRIPTION] FROM L_EYE_COLOR
SELECT PK_GENDER_ID, [DESCRIPTION] FROM L_GENDER
SELECT PK_HAIR_COLOR_ID, [DESCRIPTION] FROM L_HAIR_COLOR
SELECT PK_STATE_PROVONCE_ID, [DESCRIPTION] FROM L_STATE_PROVINCE
SELECT PK_STATUS_ID, [DESCRIPTION] FROM L_STATUS
SELECT PK_TITLE_ID, [DESCRIPTION] FROM L_TITLE
SELECT PK_TOWER_ID, [DESCRIPTION] FROM M_TOWER
SELECT PK_CITY_ID, [DESCRIPTION] FROM L_CITY
SELECT PK_REGISTER_TYPE_ID, [DESCRIPTION] FROM L_REGISTER_TYPE
Here is my frontend coding to fill dataset.
OpenConnection();
adp.Fill(ds);
CloseConnection(true);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
解决
可能这可以通过在返回表中添加额外的列然后在 C# 代码中
May be this could be the work around by adding an extra column in returning table
Then in C# code
这可能会帮助将数据源表映射到数据集表
Probably this would help Mapping Data Source Tables to Dataset Tables
我会投入时间使用 类型化数据集,会产生很多事情变得容易多了。
请记住,您可能会在一三个月内再次使用此代码。 :)
I would have invested time to use typed dataset, makes a lot of things much easier.
Remember you probarly will come back to this code in a month or three. :)
让第一个(或最后一个)表有一个表名称的
meta
表,其顺序与后面(或前面)的表相同。Have the first (or last) table a
meta
table of table names in the same order as the following (or preceding) tables.MS 表映射完全是个笑话。
有什么区别?
当我们无法保证应用程序中返回的表的顺序时,
需要的是 STRONG-NAME 匹配......查看我的解决方案< /a>
MS table mapping is a total joke.
What is the difference between
when we have no guarantee of the order of tables returned within our application.
The need is a STRONG-NAME match.... See my solution