Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 10th, 2003, 04:26 PM
Registered User
 
Join Date: Dec 2003
Location: Lisbon, Lisbon, Portugal.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Use Objects or just insert data directly to DB?

Hi, I have a simple doubt in my mind.
I buildin an simple Members app in VB.NET,that will be installed in several client machines and that connects to a central SQL database server to store and get list of data. The users must fill some forms to store the Member data in DB and some other search forms.
Question :
Should i create a member class, and create properties such as name, addr,phone, and other methods and use an instance of the class to insert and display the data, or should I simple skip that and insert the data from the controls, directly into Database through an simple INSERT ?

Tks in advance


PB
Reply With Quote
  #2 (permalink)  
Old December 10th, 2003, 04:37 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

That's like asking "should I drive or wear my hat?"

If you use an entity class for the data you will still need to get that data to the database whether you use the ado.net data objects to create a new row or do a simple insert statement.

If you are building just a simple application, you might want to just use the controls. But simple applications have a tendency to grow quickly so you aught to consider that as well.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #3 (permalink)  
Old December 10th, 2003, 04:45 PM
Registered User
 
Join Date: Dec 2003
Location: Lisbon, Lisbon, Portugal.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, but in case this simple app becomes a little more complex, what are the real advantages of starting to use entity Classes and objects to manipulate the data. I just want to get the data in the Database via the simplest way.

tks in advance




PB
Reply With Quote
  #4 (permalink)  
Old December 10th, 2003, 05:07 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Well, the simplest way would be to just code everything into the event handlers in the form. But if you need to work with the DB in other forms, or more repetitively, you should concider entity classes with data controllers. These can live in other .vb files so you can keep things clean and keep your data access in one place and the UI in another.

Advantages: the interface of the application can deal with objects and let the data controllers deal with loading and saving the data in those objects. Plus, you then can pass around a structured set of data as a single entity instead of having a clutter of variables. You could expand and create collections of the objects if you had the need. In short it comes down to separation of tiers (presentation, business logic, data access) and code reuse.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export data into the xls Sheet Directly without cl Kali Charan Tripathi Reporting Services 0 October 9th, 2008 06:40 AM
How to pass data directly into datareport . baburam VB How-To 1 May 23rd, 2006 03:43 AM
how to Insert data into external db method Access VBA 5 May 4th, 2005 10:59 AM
INSERT INTO <--inserting data into db abbylee26 Classic ASP Databases 2 March 11th, 2004 05:33 PM
Intercept data sent to printer & insert into DB tricia412 VS.NET 2002/2003 0 September 8th, 2003 02:14 PM



All times are GMT -4. The time now is 04:05 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.