Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding Rows and Constraints
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00819978
Message ID:
00820897
Views:
16
>DataRowCollection.Add() has an overloaded method that take Object Array as an argument. This would be the simplest way to resolve not-null constraints.
>
>As far as PK goes, can't you fetch the next ID from SQL Server for blank record? The only problem is if you don't use it, it will be wasted.

Yeah, that's what I already do, but it happens later... See the point is this: There's a generic routine that just gets a blank record which is useful in many places (such as if an error occurs to clear out the reference and still have a valid object in place for editing etc.).

The data assignments happen later. Sure I can delay adding the record to the DataTable[] but it gets progressively more involved later on because now all inherited code that overrides any of the methods that do this must remember to add the row explicitly!

As I said I have a hack that works, but I don't like it <g>...

+++ Rick ---






>
>>I've run into an issue in my business object layer after making some changes to the way I handle local data state.
>>
>>My bus objects create DataRows on the client dynamically and may not post them to the server for a while. However, all data is set on the client including IDs (which are retrieved from the server via StoredProc).
>>
>>My previous approach had been to create new rows, but don't add them to the datatable until save time. This worked Ok, until I needed to directly manipulate the table data directly (rare, but done on occasion). So, I thought I'll change all this to immediately add the rows to the Table.
>>
>>BUT - there's a major problem and that is that I can't add the rows until I have some data in it. My bus layer has things like GetBlankRecord() which is supposed to get essentially blank items which get later filled with more data.
>>
>>The problem here is that the data has constraints attached. Such as a Pk and non-nullable fields with nulls that won't allow me to add the row. I get things like Pk can't be null or Pk value not unique (if I prefill with 'empty' data).
>>
>>Short of dumping the Constraints from the Table is there a way to manage this?
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Reply
Map
View

Click here to load this message in the networking platform