微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

以含临时表的存储过程创建类型化数据集时报错

I've been struggling for the past couple months to use the Visual Studio XSD tool to create typed datasets from my stored procedures.  But I always get an error telling me the temp table is an invalid object name.  I've just discovered that temp tables are actually not allowed in this tool, due to the way it writes the schema to XML (see this article and this article for details).  There are a couple things about typed datasets that would make my life MUCH easier, so I'm still hoping there's a workaround for this...  Does anyone kNow how to create a typed dataset using a stored procedure that creates a temp table?  One of the articles I linked to mentions using the SET FMTONLY ON within the stored procedure, but when we tried that we either got NO results or a sql exception. 
How do I configure a sqlDataAdapter to use the results of a temporary table from a stored procedure?
I also want to produce a strongly typed dataset from the sqlDataAdapter. The VS wizard states "Invalid object name '#MyTempTable'" The table mappings is empty.

Solution:
1)VS has only a limited ability to retrieve tabular Metadata from stored procedures, and as you have discovered, temp tables are beyond those limits. You should have a dummy table or view in your database which has the same structure as your temp table. In essence this "publishes" the temp table Metadata to the world and lets you easily build strongly-typed datasets from it.

2)you can create the schema directly with the schema tool.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐