473,595 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlDataDocument error with DataSet relationships set

I have a dataset.

I fill it with two recordsets from SQL queries.

Tables are called tblPlanFYSpendi ngStage, tblSpendingStag e.

I then define the relationships between the two.

So far everything is fine. However, when I attempt to instantiate a new XmlDataDocument using the dataset I get an "Object reference not set to an instance of an object" exception.

I have another set of relationships that are almost identical and that works fine. Any thoughts?

Here is the code and error:

*************** *************** *********

objQueries.tblP lanFYSpendingSt age(dstDS);
objQueries.tblS pendingStage(ds tDS);

objQueries.Defi neRelationships (dstDS);
xdForm1370Data = new XmlDataDocument (dstDS); <<<<<<<<<thro ws error here

public void tblPlanFYSpendi ngStage(DataSet dstDS)
OleDbDataAdapte r dadBPA;

string sQuery;

sQuery = "SELECT " +
" tblPlanFYSpendi ngStage.PlanFYS pendingStageID as PlanFYSpendingS tageID, " +
" tblPlanFYSpendi ngStage.PlanID as PlanID, " +
" tblPlanFYSpendi ngStage.Spendin gStageID as SpendingStageID , " +
" tblPlanFYSpendi ngStage.FYOffse t as FYOffset, " +
" tblPlanFYSpendi ngStage.Cap as Cap, " +
" tblPlanFYSpendi ngStage.Exp as Exp " +
"FROM tblPlanFYSpendi ngStage " +
"WHERE " +
" tblPlanFYSpendi ngStage.PlanID= " + PlanID + " " +
" tblPlanFYSpendi ngStage.Spendin gStageID, tblPlanFYSpendi ngStage.FYOffse t" +

// open up the connection
conBPA = new OleDbConnection (sConn);

// get record set
dadBPA = new OleDbDataAdapte r(sQuery, conBPA);

// add to data set
dadBPA.Fill(dst DS, Constants.PlanF YSpendingStage) ;

// set primary key
dstDS.Tables[Constants.PlanF YSpendingStage].PrimaryKey = new DataColumn[] {dstDS.Tables[Constants.PlanF YSpendingStage].Columns["PlanFYSpending StageID"]};


conBPA.Dispose( );
dadBPA.Dispose( );
public void tblSpendingStag e(DataSet dstDS)
OleDbDataAdapte r dadBPA;

string sQuery;

sQuery = "SELECT " +
" tblSpendingStag e.SpendingStage ID as SpendingStageID , " +
" tblSpendingStag e.SpendingStage as SpendingStage, " +
" tblSpendingStag e.SpendingCat as SpendingCat, " +
" tblSpendingStag e.Tag as Tag, " +
" tblSpendingStag e.CapAlias as CapAlias, " +
" tblSpendingStag e.ExpAlias as ExpAlias " +
"FROM tblSpendingStag e " +
" tblSpendingStag e.Sort" +

// open up the connection
conBPA = new OleDbConnection (sConn);

// get record set
dadBPA = new OleDbDataAdapte r(sQuery, conBPA);

// add to data set
dadBPA.Fill(dst DS, Constants.Spend ingStage);

// set primary key
dstDS.Tables[Constants.Spend ingStage].PrimaryKey = new DataColumn[] {dstDS.Tables[Constants.Spend ingStage].Columns["SpendingStageI D"]};


conBPA.Dispose( );
dadBPA.Dispose( );

public void DefineRelations hips(DataSet dstDS)
dstDS.Relations .Add("SpendingS tage_to_PlanFYS pendingStage",
dstDS.Tables[Constants.Spend ingStage].Columns["SpendingStageI D"],
dstDS.Tables[Constants.PlanF YSpendingStage].Columns["SpendingStageI D"]);
dstDS.Relations["SpendingStage_ to_PlanFYSpendi ngStage"].Nested = true; // allows nested XML


*************** *************** ************

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.NullRefe renceException: Object reference not set to an instance of an object.

Source Error:

Line 87:
Line 88: xdForm1370Data = new XmlDataDocument (dstDS);
Line 89:
Stack Trace:
[NullReferenceEx ception: Object reference not set to an instance of an object.]
System.Xml.XmlD ataDocument.OnN estedParentChan ge(DataRow child, XmlBoundElement childElement, DataColumn childCol)
System.Xml.XmlD ataDocument.OnA ddRow(DataRow row)
System.Xml.XmlD ataDocument.Loa dTreeFromDataSe t(DataSet ds)
System.Xml.XmlD ataDocument.Bin d(Boolean fLoadFromDataSe t)
System.Xml.XmlD ataDocument.Ini t(DataSet ds)
System.Xml.XmlD ataDocument..ct or(DataSet dataset)
BPA.for1370.Bui ldSections() in c:\inetpub\wwwr oot\bpa\form137 0.aspx.cs:88
BPA.for1370.Pag e_Load(Object sender, EventArgs e) in c:\inetpub\wwwr oot\bpa\form137 0.aspx.cs:69
System.Web.UI.C ontrol.OnLoad(E ventArgs e)
System.Web.UI.C ontrol.LoadRecu rsive()
System.Web.UI.P age.ProcessRequ estMain()

Nov 18 '05 #1
0 1423

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: gilly3 | last post by:
Reposting to a more relevant group. I am passing a generic dataset into a new XMLDataDocument and then parsing the XML with XSLT. The idea being that I can parse any dataset with the same xslt, and dynamically generate an html table. The problem is when the DataSet contains a null value, the node for that record is not created. Then when the xml parses it, there are too few cells in some of the table rows. I can think of a couple...
by: James Ankrom | last post by:
Why does this fail? Dim relResources As New Data.DataRelation("Application_Resources", ..Tables("User_Applications").Columns("Application_id"), ..Tables("Resource_Rights").Columns("Application_id"), False) mUserData.Relations.Add(relResources) relResources.Nested = True Dim UserDataXML As System.Xml.XmlDataDocument = New System.Xml.XmlDataDocument(mUserData)
by: Derrick | last post by:
I am reading in xml files that equate to sql tables, via XmlDataDocument, and then operating on the DataSet. With the most simple app that just loads the xml doc, I see the memory footprint of the app grow to roughly 5x the size of the xml document after the xml doc is read. Can anyone comment on this? Is this expected? Below are two samples, the first hits northwind, and creates a 19meg (roughly, on my machine) xml file. The second...
by: deko | last post by:
I create an XmlDataDocument Dataset when the main form of my WinForms app opens. The user will make changes to the Dataset, and then those changes should be saved to the XML file when the code runs xdd.Save(xmlFile). But I get an error when I try to save the Dataset back to the XML file: "The process cannot access the file "C:\Projects.xml" because it is being used by another process." Is this because I'm in Debug mode? How do I persist...
by: Adrian Meyer | last post by:
Hi, On the server I code the following web service: ))] public XmlDataDocument GetTypedXmlDataDocument() { sqlDataAdapter1.Fill(typedDataSet1); XmlDataDocument dataDoc
by: jmagaram | last post by:
I have a DataSet I want to work with as Xml using XmlDataDocument. I can't figure out how to query the resultant Xml using XPath. From the following XML below, what XPath query will return the list of orders for each Male customer? Because some tables in my DataSet have >1 foreign key columns, it is not possible to set up a nested DataRelation for all relationships - a DataTable can only be the child of at most one nested DataRelation. As...
by: JD | last post by:
I have a DataGridView with a DataSet as DataSource. The user can update the contents of the DataGridView, and then click on a Save button to save the data to an XML file. When they click on Save, I call the subroutine below. The first time that I call it, it works fine. However, if the user makes some more changes in the DataGridView and then wants to save again, I get the following error message: "DataSet can be associated with at...
by: ERingmae | last post by:
Hi, The environment is .NET 2.0, the language is C# and the problem is reading XSD file with xs:redefine section correctly to a XMLDataDocument.DataSet. What I am trying to do: I am trying to create a DataSet object from an XSD file by using XMLDataDocument class.
by: david.juffermans | last post by:
Hi, I have a problem reading xml into a dataset using the XmlDataDocument. In a test project, I created the following xml file: <?xml version="1.0" standalone="yes"?> <Customer> <OrderDetails> <OrderID>5</OrderID> <ProductID>6</ProductID>
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.