>>To get it into your GridView you will still need to select the data, so it's the same as 'SELECT * from ' + ... - no point of the temp table at all unless you want to re-use it for other statements (but since you don't have any conditions, I still don't see a point).
>>
>>So, you will need oCommand.ExecuteReader() instead of NonQuery and you will need to do oConn.Close() as normal to close the connection.
>
>Yes, it would not be obvious why the temp table based on my sample. In truth it will take about 2 pages of code to generate it. The sample was just conceptual. And . . . I had tried the Reader approach but didn't get any result. So this is what I have now.
>
>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
>
> Dim SQL As String
> SQL = "SELECT * INTO #TempConstraint FROM [ApprovedFunding]"
> Dim oConn As New SqlConnection(ConfigurationManager.ConnectionStrings("TIPConnectionString").ConnectionString)
> Dim oCommand As New SqlCommand(SQL, oConn)
>
> oConn.Open()
> oCommand.ExecuteNonQuery()
> oCommand.CommandText = "SELECT * FROM #TempConstraint"
>
> Dim oReader As SqlDataReader
> oReader = oCommand.ExecuteReader()
> oReader.Read()
>
> GridView1.DataSource = oReader
>
>
> End Sub
>Can you tell me what I'm missing? Perhaps it belongs somewhere other than Page.Load?
Instead of oReader.Read() can you get the number of records? Also, I forgot a little how we assign result of the reader to GridView. It is not easy, as I recall. If you would fill a DataSet, it will be a different story.
If it's not broken, fix it until it is.
My Blog