Skip to Content
Jan 30, 2009 at 02:18 PM

Fill DataTable using stored procedure


I'm getting an error "Invalid query tree " when I try to load data into a DataTable from a SQL stored procedure:

DataTable dt = myForm.DataSources.DataTables.Add("MYTABLE");

dt.ExecuteQuery("EXEC sp_myprocedure @Par1 = 10");

The SQL stored procedure creates a temporary table and fills it with data using several CTE update statements. Finally a select * from the table is returned.

The procedure works fine when run in the SQL Management Studio.

Isn't it possible to fill data into a DataTable using a SP?

SAP2007 PL 44, SQL2005, VS2008, C#, .NET 3.5


Lars Jönson