Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# - Add and Update Records
Message
From
09/04/2008 08:52:01
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
08/04/2008 20:38:07
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01309187
Message ID:
01309261
Views:
17
>>So the BizObj would do a "SELECT FROM SomeTable WHERE Key = -1" to get an empty DS back? If so, do I need to add a
>>row to use it?

>
>Well, yes and no. As I said, you'd need at least one row.
>
>But if you're using -1 as an indication that it's new stuff you're adding, why even bother hitting the database? Your biz class could take care of adding the new row to your DataSet. However, if you're not using a Typed DataSet, then I guess you *would* need to .Fill a DataSet from the database in order to get all your columns (not necessary with a Typed DataSet).
>
>~~Bonnie
>


Doesn't the chain of responsibility sort of take care of itself with regards to the Form knowing if the record is a new or an edit? The form in his case is instantiated with a -1 for the PK, then it needs to call a method on the Biz Obj that passes back data with any default values included first in the new row. Like you said, the biz obj can take care of everything, but the form is going to know because it is in the chain of responsibility.

This is good discussion because it helps to set out how the process could/should work.
Tim

>
>
>>>>One thing I'm still confused on is this; The Biz Class gets the DS, then passes it to the form, then the form binds
>>>>the DS to controls?

>>>
>>>Not quite. The Form asks the Biz class for the DataSet.
>>>
>>>>And like Tim asked, how does the form know if it's going to be in Add or Edit mode? Could check to see if the DS has
>>>>any records?

>>>
>>>Why does the form need to know this? If you're adding a new record, the Biz class will pass back a DataSet that has no data, but it won't be totally empty. You would need at least one row, but that would be basically an empty row, DBNulls or whatever defaults you have (not totally empty I suppose ... you may have more than one table in your DataSet, with child tables, etc. ... but let's assume you start with something simple).
>>>
>>>Why does the form care if it's new data or if you're editing old data?
>>>
>>>~~Bonnie
>>
>>
>>Because I don't know any better? I guess I was thinking that I would need to know weather to do an insert or update
>>when the user clicks save, but the DS handles that, doesn't it?
>>
>>So the BizObj would do a "SELECT FROM SomeTable WHERE Key = -1" to get an empty DS back? If so, do I need to add a
>>row to use it?
Timothy Bryan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform