tjgquicken
asked on
Upgrading to .NET 2.0 error message
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.
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.
When you upgraded your code it might have not convert properly one of your dataset, check that all the column are present in them.
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.
Regards,
Max.
ASKER
Here's the line of code that's throwing the exception:
fileGuestRel = new DataRelation( "fileGuestRel", filesTable.Columns["file_i d"], guestTable.Columns["file_i d"] );
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.
fileGuestRel = new DataRelation( "fileGuestRel", filesTable.Columns["file_i
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.
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
If you are building the DataTbale dinamillcly could you post that code too Thank you
ASKER
In my code, right before the line that constructs the DataRelation, I have
HttpContext.Current.Trace. Write("fil esTable.Co lumns[\"fi le_id\"] = " + filesTable.Columns["file_i d"].ToStri ng());
HttpContext.Current.Trace. Write("gue stTable.Co lumns[\"fi le_id\"] = " + guestTable.Columns["file_i d"].ToStri ng());
The trace output on my web page reads:
filesTable.Columns["file_i d"] = file_id
guestTable.Columns["file_i d"] = 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?
HttpContext.Current.Trace.
HttpContext.Current.Trace.
The trace output on my web page reads:
filesTable.Columns["file_i
guestTable.Columns["file_i
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?
fileGuestRel = new DataRelation( "fileGuestRel", filesTable.Columns["file_i d"], guestTable.Columns["file_i d"], /*you have a flag constraint here*/ false );
Also the DataTables are they in the same DataSet?
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.