Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 27th, 2005, 09:37 AM
Registered User
 
Join Date: Sep 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Data displayed wrong in ASP .NET DataGrid

I am currently maintaining an ASP .NET application that connects to a SQL Server 2000 database. Everything has worked fine (as far as I know) until now.

When I open a view in SQL Server, all data is returned correctly. When I open this same view with a DataReader or DataAdapter (tried both to see if one or the other was a problem), I am able to view the correct results as well. The problem occurs when I bind the resulting datareader or datatable to a datagrid. I have a column that should have information in it (as it shows up in SQL Server or the Watch Window in Visual Studio), but the DataGrid displays the column as empty.

There are no errors that occur: The app uses On Error GoTo, so when I debug I have break points at every function and subroutine. I have also walked through the debug step-by-step. There are no problems at all, and like I said before, I can view the table and datareader contents in the watch window and it shows up correctly.

Here is the Databind code:

        Dim objGF As New GeneralFunctions
        Dim ReturnedResults As New DataTable
        ReturnedResults = objGF.GetDataSet(Global.gConn, strSQL) ' Returns a datatable from a dataadapter

        If ReturnedResults.Rows.Count < 1 Then
            'turn off datagrid
            OurDataGrid.Visible = False
            lblResults.Text = "No Entries found in the Database."
        Else
            'bind data
            lblResults.Text = ""
            OurDataGrid.Visible = True
            OurDataGrid.DataSource = ReturnedResults 'setup <asp:datagrid> tag
            OurDataGrid.DataBind() 'attach data from db to asp datagrid
        End If




Here's the function for filling the DataSet

Public Function GetDataSet(ByVal Conn As String, ByVal QueryStr As String) As DataTable
        On Error GoTo ErrHand

        'setup SQL db connection
        Dim OurConnection As New OleDbConnection 'connection
        Dim OurCommand As OleDbCommand 'sql command
        Dim OurDataAdapter As New OleDbDataAdapter 'results from sql statement
        Dim dsResults As New DataTable

        OurConnection = New OleDbConnection(Conn) 'set sql string to Conn
        OurCommand = New OleDbCommand(QueryStr, OurConnection) 'setup sql command
        OurDataAdapter.SelectCommand = OurCommand
        OurDataAdapter.Fill(dsResults)

        Return dsResults

ExitFunct:
        If Not OurCommand Is Nothing Then
            OurCommand = Nothing
        End If
        If Not OurDataAdapter Is Nothing Then
            OurDataAdapter = Nothing
        End If
        If Not OurConnection Is Nothing Then
            OurConnection = Nothing
        End If

        Exit Function

ErrHand:
        Resume ExitFunct

    End Function



Any help will be appreciated. I have searched Google and Microsoft for any possible known issues with the DataGrid displaying contents incorrectly, but with no results.

Thanks.

 
Old September 27th, 2005, 01:12 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

   The only thing I can think of is that you have some databindgs properties set for the datagrid in the properties window.

 
Old September 28th, 2005, 08:39 AM
Registered User
 
Join Date: Sep 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No, I don't have any databinding done in the properties box. Everything is done with late-binding because the information all comes from SQL Server 2000.






Similar Threads
Thread Thread Starter Forum Replies Last Post
what is wrong? I'am a beginner of asp.net. dqfverygood Wrox Book Feedback 16 December 19th, 2007 02:10 PM
ASP.NET Page cannot be displayed chatunlimitedc ASP.NET 1.0 and 1.1 Basics 1 April 25th, 2007 12:42 AM
The page cannot be displayed Datagrid Jose Fidalgo ASP.NET 1.0 and 1.1 Professional 1 September 26th, 2006 06:10 AM
CR in ASP.NET (C#) ... what's wrong?? psinyc Crystal Reports 1 December 15th, 2003 11:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.