简体   繁体   中英

Unable to select global temp table (##TempTable) from C#

When I try to select global temp table from win form application then I am able to read the table from any number of client, when I do the same from WCF service hosted in windows service, I am getting error saying that Invalid object name '##MyTempTable'.

At the same time I am able to select the table from winform with the same piece of code, will anyone explain me what could be possible reasons?

  1. SP is called from the data adapter dll
  2. Data Adapter (WCF) service loads this ada adaptor dll when service is started
  3. Another WCF service requests DA service for data to show the data in web client
  4. DA service is hosted in windows service as NT AUTHORITY\\NetworkService
  5. Connection string used in both winform and dll is "conString = "Data Source=.\\;" + "Initial Catalog=myDB;" + "Integrated Security=SSPI;";" I tried to pass Sa credential also in the connection string, still same behavior.

What ever I am trying to do from the dll can be done from the win form and I am not able to do from the dll used by WCF service.

Until connection who created your global temp table is live. Any other connection can access that global temp table. As soon as connection who created gloabl temp table is closed, this global temp table gets dropped automatically and any other connection trying to use it gets an exception saying Invalid object name.

MSDN

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM