1

I have a project with c# and Microsoft SQL Server, I want to populate my gridview with a stored procedure.

this procedure has a table declaration in it ( I need this @temptable for get some data from another database with opendatasource).

It is OK in SQL Server Management Studio but it doesn't populate my gridview(in c# project) when my procedure has a deceleration of a @tempTable (even I don't use it table).

how can I use @tempTable in procedure to use it in gridview?

p.s. I also tried @tmp, #tmp, ##tmp tables as well.

2 Answers 2

1

The simple answer is that unless the temporary table is created and left resident within the database, you can't connect to it as you would a normal table. @temptable is a local reference.

If you know the table definition though you could setup an appropriate data object; pass back all rows of the temporary table from the procedure; store the results in a collection of your data object and make that collection the datasource for your grid.

This would mean that you couldn'y use any drag and drop functionality from Server Explorer, but would need to code your own SQL command to retrieve that data and populate the collection.

0

the problem coused about type of connection. it was oledbconnetion and I changed it to sqlconnection, now I can use table variables in a stored procedure to select it in a grid

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.