Link to home
Start Free TrialLog in
Avatar of stewart_page
stewart_pageFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Create an SQL Temporary Table in VB.Net

I need to create a temporary table in SQL (#results) That I can then bind to a Listview to display the results a a search that will be persistant for as long as the user is logged in.  The search results fields willl vary dependant on the criteria, and the query SQL will be build up depending on the criteria, so I need to programmatically create the temporary table, populate it and then bind it to the listview.  
Clearly, static tables are no good, as different users will be searching on different things at the same time.  I know how to create temporary table in SQL natively, but need some help to create them dynamically in VBH.net.  
I don't think stored procedures are the solution either as every query will be slightly different.

Any help would be much appreciated.
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

If you create the query and run it on your database, just populate a datatable in your code. Then it's also a temporary table
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stewart_page

ASKER

Thanks great answer!  I really should have thought of that!!  I got my mind set on temp tables, and missed the obvious.  The solution is great, thanks.
Next time try to be honest with the points and if you accept an answer that's the same as another comment (with some more info), the least you can do is to split the points (give more points to the item you find the most usefull)