以含临时表的存储过程创建类型化数据集时报错
2007-10-03 10:47
375 查看
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.
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.
相关文章推荐
- 存储过程中创建临时表,为何没有权限?
- 导出文件成sql形式,创建表格之前,判断某表格是否存在,创建临时存储过程删除表格,之后再删除存储过程
- 关于sql server 在存储过程中创建临时表,并往临时表中插入数据时出现乱码的问题
- 临时存储过程和全局的存储过程的创建
- Oracle存储过程动态创建临时表/存储过程执行权限问题--AUTHID CURRENT_USER
- 创建临时表-定时刷数据的存储过程及定时job
- 在存储过程中利用游标创建临时表的方法
- 在存储过程中创建临时表
- DB2存储过程--创建临时表,返回临时表集合
- 在存储过程中创建一临时表
- 避免创建表的情况下,执行存储过程插入临时表
- 在存储过程中创建临时表来重构数据
- 恢复MySQL数据库创建存储过程是遇到错误
- 数据库回顾--存储过程的创建和应用
- SQL SERVER 2005 用ROW_NUMBER()创建分页存储过程
- sql server 存储过程的优化.(变量表,临时表的简单分析)
- 使用DELIMITER创建存储过程的用法
- 使用Toad创建存储过程出现错误并解决
- 为Sybase ASA创建外部存储过程(java示例)
- 创建存储过程,调用存储过程