Solved

Upgrading to .NET 2.0 error message

Posted on 2007-04-01
9
528 Views
Last Modified: 2013-11-07
I just upgraded my ASP.NET application from v1.1 to v2.0, and now when I run my application, I get the following error message:
Cannot create a DataRelation if Parent or Child Columns are not in a DataSet.
What does this mean, and how can I get my application working again (hopefully by changing as little code as possible)? Thanks.
0
Comment
Question by:tjgquicken
  • 5
  • 3
9 Comments
 
LVL 5

Expert Comment

by:jef06
ID: 18834912
When you upgraded your code it might have not convert properly one of your dataset, check that all the column are present in them.
0
 
LVL 19

Expert Comment

by:DreamMaster
ID: 18834923
Are you by any chance using a property "Sorted=True" in the control that generates this problem? In that case check whether or not the dataset gets sorted. It should be sorted with this property set to true..

Regards,
Max.
0
 

Author Comment

by:tjgquicken
ID: 18836300
Here's the line of code that's throwing the exception:
fileGuestRel = new DataRelation( "fileGuestRel", filesTable.Columns["file_id"], guestTable.Columns["file_id"] );
Both filesTable and guestTable are of type DataTable, not DataSet. Is there an easy way to convert them to DataSets, or is there another DataRelation constructor that takes DataTables as parameter. Again, this worked fine in v1.1, so I don't really want to change anything major if that can be avoided. Thanks.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 5

Expert Comment

by:jef06
ID: 18836341
Of course you can have DataRelation only in DataTable, could you tell me if the table filesTable and guestTable have the file_id column, also do they have EnforceConstraint  =True;
If you are building the DataTbale dinamillcly could you post that code too Thank you
0
 

Author Comment

by:tjgquicken
ID: 18836459
In my code, right before the line that constructs the DataRelation, I have
HttpContext.Current.Trace.Write("filesTable.Columns[\"file_id\"] = " + filesTable.Columns["file_id"].ToString());
HttpContext.Current.Trace.Write("guestTable.Columns[\"file_id\"] = " + guestTable.Columns["file_id"].ToString());

The trace output on my web page reads:
filesTable.Columns["file_id"] = file_id
guestTable.Columns["file_id"] = file_id
So I assume that both tables have a "file_id" column.

Neither DataTable is dynamically created. They're both hard-coded SQL queries to a MSSQL database.
I don't know how to tell if EnforceConstraint=True. How do I do that?
0
 
LVL 5

Expert Comment

by:jef06
ID: 18836504
fileGuestRel = new DataRelation( "fileGuestRel", filesTable.Columns["file_id"], guestTable.Columns["file_id"], /*you have a flag constraint here*/ false );
0
 
LVL 5

Expert Comment

by:jef06
ID: 18836510
Also the DataTables are they in the same DataSet?
0
 

Author Comment

by:tjgquicken
ID: 18836622
As for EnforceConstraint, I used the version of the constructor that takes no boolean variable, so it's whatever the default is. I don't have any DataSets defined in my code, so again, I think it's whatever the default is -- whether they all go into the same DataSet or different DataSets.
0
 
LVL 5

Accepted Solution

by:
jef06 earned 500 total points
ID: 18836673
Ok it look like we needs to have this two DataTable in one DataSet.

Look at that link
http://blogs.netindonesia.net/ridi/archive/2006/01/02/8244.aspx
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now