Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# - Add and Update Records
Message
From
08/04/2008 20:38:07
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01309187
Message ID:
01309216
Views:
24
>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




>>>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?
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform