Datagrid not displaying

D

Dave

I'm tearing my hair out over this one. I have a newbie's grasp of data
grids in vb.net, i.e. I have successfully taken working code, and made it
work on my applications. I am unsuccessful at this one, however - I am
trying to use a temporary table to load a grid. I do not get any errors
running my code, I just don't get the data grid to appear on my web form.

I'm using SQL Server 2000 and Visual Studio 2003. The query you see
collects 499 records when I run it in Query Analyzer.

Can somebody tell me if they see any obvious errors in my code - syntactic
or conceptual? Thanks very much in advance.

Dave

Function MyFunction() as Boolean

Dim sql As String = "SELECT Observation, Issue, Description "

sql &= "INTO #tmpMultipleTableAggregate "
sql &= "FROM tblLkpAssociatedIssues [L], tblIssueMaster "
sql &= "WHERE L.Issue = i.IssueNumber "
sql &= "ORDER BY Observation, L.Issue "

Dim con As New SqlConnection(sConnect) 'sConnect is a global constant
Dim cmd As New SqlCommand(sql, con)
Dim adapter As New SqlDataAdapter(cmd)
Dim dsIssueTracking As New DataSet

con.Open()
adapter.Fill(dsIssueTracking, "#tmpMultipleTableAggregate")
con.Close()

'Load the data grid with the temporary table culled from two other tables
grdLink.DataSource = dsIssueTracking.Tables("#tmpMultipleTableAggregate")
grdLink.Enabled = True
grdLink.Visible = True

grdLink.DataBind()

End Function
 
E

Eliyahu Goldin

Hey Dave, your query doesn't produce any record set! 499 records go to the
temp table instead of getting down to your application.

Get rid of "INTO #tmpMultipleTableAggregate " part. You don't need any temp
tables. Data adapter will build a table named "Table" based on your SELECT
results. Make a call
adapter.Fill(dsIssueTracking)
and databind the grid to table "Table".

Eliyahu
 
D

Dave

Wow! Nice explanation and nice solution. A one-minute fix - my favorite
kind.

For the benefit of my fellow newbies, when Eliyahu says
"... and databind the grid to table 'Table'.", he means use this:
grdLink.DataSource = dsIssueTracking.Tables("Table")

Thank you very much, Eliyahu.

Dave



Eliyahu Goldin said:
Hey Dave, your query doesn't produce any record set! 499 records go to the
temp table instead of getting down to your application.

Get rid of "INTO #tmpMultipleTableAggregate " part. You don't need any temp
tables. Data adapter will build a table named "Table" based on your SELECT
results. Make a call
adapter.Fill(dsIssueTracking)
and databind the grid to table "Table".

Eliyahu

Dave said:
I'm tearing my hair out over this one. I have a newbie's grasp of data
grids in vb.net, i.e. I have successfully taken working code, and made it
work on my applications. I am unsuccessful at this one, however - I am
trying to use a temporary table to load a grid. I do not get any errors
running my code, I just don't get the data grid to appear on my web form.

I'm using SQL Server 2000 and Visual Studio 2003. The query you see
collects 499 records when I run it in Query Analyzer.

Can somebody tell me if they see any obvious errors in my code - syntactic
or conceptual? Thanks very much in advance.

Dave

Function MyFunction() as Boolean

Dim sql As String = "SELECT Observation, Issue, Description "

sql &= "INTO #tmpMultipleTableAggregate "
sql &= "FROM tblLkpAssociatedIssues [L], tblIssueMaster "
sql &= "WHERE L.Issue = i.IssueNumber "
sql &= "ORDER BY Observation, L.Issue "

Dim con As New SqlConnection(sConnect) 'sConnect is a global constant
Dim cmd As New SqlCommand(sql, con)
Dim adapter As New SqlDataAdapter(cmd)
Dim dsIssueTracking As New DataSet

con.Open()
adapter.Fill(dsIssueTracking, "#tmpMultipleTableAggregate")
con.Close()

'Load the data grid with the temporary table culled from two other tables
grdLink.DataSource = dsIssueTracking.Tables("#tmpMultipleTableAggregate")
grdLink.Enabled = True
grdLink.Visible = True

grdLink.DataBind()

End Function

 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top