datagrid data not showing up

B

Brent Burkart

I have a datagrid that simply shows readonly data that i pull using sql.
This was working fine and one day it stopped working.

It shows the headers, but no data. Can anyone point me in the right
direction? I am stuck.
 
M

Michael

Sure there is data in your datasource to be shown? Without posting any code
it is going to be very hard to help you.
 
B

Brent Burkart

I have checked this and I have hooked up Profiler to see if my query is
working. Not sure how to check for the data being returned. I assume it is
since I am checking for present data in a Sqldatareader.

Here is my code

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here


get_data()

Populate_Fields()

End Sub

Sub get_data()


myConnection = New SqlConnection("x")

myConnection.Open()

myCommand = New SqlCommand("select
BLASTNAME,BFIRSTNAME,BSOCSECNO,loan.LOANNUM,APPLTYPE,LOANSTAT,PROPADDR1 from
borrower, propchar, loan where loan.loanid = borrower.loanid and loan.loanid
= propchar.loanid and borrower.borrowercount = 1 and BSOCSECNO = '" &
Trim(Request.QueryString("SSN")) & "'", myConnection)

myDatareader = myCommand.ExecuteReader()

End Sub

Sub Populate_Fields()

If myDatareader.Read Then

myDataGrid.DataSource = myDatareader

myDataGrid.DataBind()

Else

Label1.Text = "No data found corresponding to an SSN of " &
Request.QueryString("ssn")

End If

myDatareader.Close()

myConnection.Close()

myDatareader = Nothing

myConnection = Nothing

myCommand = Nothing

End Sub
 
B

Brent Burkart

Yeah, the query works. I am not sure what else to check. I even ran it
agains Profiler to make sure the query runs.

Thanks
 
B

Brent Burkart

yeah, I have taken the query that is generated and ran it in Query Analyzer.
I pulls back data. I have posted my code in a post below.

Thanks
 
B

Brent Burkart

I figured it out. In these cases there was only one record. When I checked
to see if data exists
If mydatareader.read
I was eating up my first record. So when I bound the data, there was none
left. I have to find another way to check for data.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top