#temp table not recognized when sqlcommand has parameters

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dim da As New SqlDataAdapter("select * into #temp1 from tbl1 where ID = 9",
conn)
conn.open
da.selectcommand.commandtext = "select * from #temp1"
Dim dr As SqlDataReader = da.selectcommand.executereader

works OK ---- But

Dim da As New SqlDataAdapter("select * into #temp1 from tbl1 where ID =
@ID", conn)
da.selectcommand.Parameters.Add(new sqlparameter("@ID", sqldbType.Int, 2)
da.selectcommand.Parameters("@ID").value = 9
conn.open
da.selectcommand.commandtext = "select * from #temp1"
Dim dr As SqlDataReader = da.selectcommand.executereader

(nevermind the syntax above) - when I use a parameter and try to use a #temp
table - ado no longer recognizes the #temp table as when I just add the
criteria as part of the sql string. Is there a way to use parameters and use
#temp tables in the same queries?

Thanks,
Rich
 
AFAIK there are still issues with ADO.NET and #temp queries that have not
been resolved.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
Between now and Nov. 6th 2006 you can sign up for a substantial discount.
Look for the "Early Bird" discount checkbox on the registration form...
 
Back
Top