Accessing sql server temporary table from asp.net

What I am missing to get data from temporary table. This is showing error like Invalid object name #emp. Please help me I am using Asp.net.

 Dim sqlcmd = New SqlCommand("select * into #emp from employees", conn)
 sqlcmd.ExecuteNonQuery()

 sqlcmd = New SqlCommand("select * from  #emp", conn)
 Dim dr As SqlDataReader = sqlcmd.ExecuteReader

See Above query is working fine and data is going into temporary table. but it is not selecting again through second one query.

Thanks

Answers


Try to use Global Temporary table instead of Local Temporary tabel like.. ##emp

or

you can Just use StoreProcedure which has all the Sql statement you want to execute and return your desired Recordset.


Need Your Help

profiling a sample program of JAAS

java exception profiling jaas

I am trying to profile a sample program of JAAS which is here.(http://www.devx.com/getHelpOn/Article/9915/0/page/4). I downloaded the code and run it. Without profiling it runs just fine. The comma...

Why are these Images bigger then origional size?

javascript jquery css image

I have multiple images that I pull from facebook. They are placed in a scroller. When you click on the image a dialog appears with the actual image (The images in the scroller are thumbnail size, w...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.