S
Shawn Ferguson
Hello All,
I'm starting to learn C# and OOP to become a better programmer, however I;m getting frustrated. It's tough, but what is making it really tough for me is trying to do everything with objects in mind. Here is a typical example of a scenario that I could choose different ways to approach. I have a class called Pet. Pet has an insert, update, delete, get all, get specific methods inside the class. I have a form that has the pet properties (fields) on it. I want to insert the pet (fields) properties inside a database when someone clicks the Insert Button. The first method I tried was to use the ObjectDataSource control. It doesn't work, it gives me errors on the ControlID, then when I add a control ID, it gives me a different error "Target Invocation Exception" on the ObjectDataSource.Insert() method.
So...my second thougt is to abandon the ObjectDataSource idea completely and use the methods of the object when events such as Button clicks occur. That would mean, for every button click, add, getall, edit, delete - the same object would need to be created and I would used it's proper method. It seems expensive, redundant, and not how one should use objects, but at the same time, it seems easier to understand. What are your thoughts? Thank you for all responses - frustrated, but hopeful!!!
I'm starting to learn C# and OOP to become a better programmer, however I;m getting frustrated. It's tough, but what is making it really tough for me is trying to do everything with objects in mind. Here is a typical example of a scenario that I could choose different ways to approach. I have a class called Pet. Pet has an insert, update, delete, get all, get specific methods inside the class. I have a form that has the pet properties (fields) on it. I want to insert the pet (fields) properties inside a database when someone clicks the Insert Button. The first method I tried was to use the ObjectDataSource control. It doesn't work, it gives me errors on the ControlID, then when I add a control ID, it gives me a different error "Target Invocation Exception" on the ObjectDataSource.Insert() method.
So...my second thougt is to abandon the ObjectDataSource idea completely and use the methods of the object when events such as Button clicks occur. That would mean, for every button click, add, getall, edit, delete - the same object would need to be created and I would used it's proper method. It seems expensive, redundant, and not how one should use objects, but at the same time, it seems easier to understand. What are your thoughts? Thank you for all responses - frustrated, but hopeful!!!