Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 August 8th, 2003, 03:13 AM
Authorized User
 
Join Date: Aug 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default dataGrid Error message

Please help with this Error message:

Object variable or With block variable not set.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object variable or With block variable not set.

Source Error:


Line 38: dbCommand = New SqlCommand("sp_DisplayCommiteeInformation", DataConn)
Line 39: DataConn.Open()
Line 40: dgCommitee.datasource = dbCommand.ExecuteReader(CommandBehavior.CloseConne ction)
Line 41: dgCommitee.databind()
Line 42: 'DataConn.Close()


Source File: c:\inetpub\wwwroot\AIA\AIA\Commitee.aspx.vb Line: 40

Stack Trace:


[NullReferenceException: Object variable or With block variable not set.]
   Microsoft.VisualBasic.CompilerServices.LateBinding .InternalLateSet(Object o, Type& objType, String name, Object[] args, String[] paramnames, Boolean OptimisticSet, CallType UseCallType) +1661
   Microsoft.VisualBasic.CompilerServices.LateBinding .LateSet(Object o, Type objType, String name, Object[] args, String[] paramnames) +28
   AIA.Commitee.BindCommiteeInfo() in c:\inetpub\wwwroot\AIA\AIA\Commitee.aspx.vb:40
   AIA.Commitee.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\AIA\AIA\Commitee.aspx.vb:26
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +29
   System.Web.UI.Page.ProcessRequestMain() +724


---------------------------------------------------
My code:

    Sub BindCommiteeInfo()
        Dim myConnection As New SqlConnection()
        Dim SQLServer As String = "server=localhost;database=AIA;Trusted_Connection= yes"
        Dim DataConn As SqlConnection
        Dim dbCommand As SqlCommand
        DataConn = New SqlConnection(SQLServer)
        Dim dgCommitee
        dbCommand = New SqlCommand("sp_DisplayCommiteeInformation", DataConn)
        DataConn.Open()
        dgCommitee.datasource = dbCommand.ExecuteReader(CommandBehavior.CloseConne ction)
        dgCommitee.databind()
        'DataConn.Close()


    End Sub

Sanjeet
__________________
Sanjeet
 
Old September 20th, 2003, 09:41 AM
Registered User
 
Join Date: Sep 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm not sure about this sanjeet but i think a DataReader is [u]not</u> a valid source for a datagrid. Check line# 40.

You can use any of the following instead: DataTable, DataView, DataSet.





Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the error message for a 500 server error? chobo2 C# 2005 1 May 4th, 2008 03:11 AM
Error message radconchuck ASP.NET 1.0 and 1.1 Basics 0 July 3rd, 2007 01:13 PM
Error Message Louisa ASP.NET 1.0 and 1.1 Basics 1 October 14th, 2005 06:35 AM
error message jokeshing SQL Server 2000 3 July 9th, 2004 05:15 AM





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