Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 23rd, 2005, 03:39 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default Which is the best ADO.Net way ?

Suppose, I am creating a barrister manager using ASP.Net and CS.

My aspx page contains the form which collects details of barrister. Then there is a data grid which displays all barristers in database.

My code behind page can do the add / edit / delete operations in 2 ways.

1) I can create a connection object and command object. Then I can create the insert / update / delete query out of the values posted. (May also use stored procedure and send posted values as parameters). Then I can use the ExecuteNonQuery method of command object to run these queries.

2) I can create a data adapter and a dataset. Then using the AddRow, DeleteRow or Updaterow methods of adapter object, I can add data.

My doubt is which method is better and more professional ?

Why there are two methods ?
  #2 (permalink)  
Old April 23rd, 2005, 03:03 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

My take on this subject is that WebForms favors one way while WinForms favors another. Although I'll make the disclaimer that I do not work with WinForms regularly and my opinions are based on what I have read in articles and in questions on this board.

When I'm in WebForms, most of the time I make database update calls with Command.ExecuteNonQuery(). This seems most logical to me because WebForms is working with stateless data. Depending on the scope of my data retreival code (is it in the webform code-behind or a data access layer) I will use either the DataAdapter/DataSet or Command/DataReader. Seeing as most of the time in webforms you are making one-off data hits to the database it makes more sense to use small clean queries with the ExecuteNonQuery method instead of setting up all the objects for a dataset Add/Delete/Update.

On the flip side, when working with a WinForms application your data is stateful because the program is 'living' in memory (versus the statelessness single-page execution of webforms). In this scenario it would seem to make more sense to work with your data in a disconnected (but stateful) nature and use the Add/Update/Delete functionality that you can take advantage of in a stateful application.

I doubt that either method you describe is any better or more professional than the other. However, as most techniques in programming go, one has a more suitable use than the other depending on the scenario, and what's more professional is knowing which one to use.

-Peter
  #3 (permalink)  
Old April 25th, 2005, 03:25 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Hello Planoie,

Thanks for the reply.

I am new to winforms. I have not used it anywhere. I think, it is to be used in VB7. Can I use a winform in a web application ?
  #4 (permalink)  
Old April 25th, 2005, 07:58 AM
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

Not natively. Hence the names WinForms and WebForms. If you build a completely HTML based application in ASP.NET, you have to use WebForms only.

The line between windows (desktop) applications and web (browser based) applications is going to start getting very blurry. You can have a web "based" application that actually downloads windows forms that talk to web services so you have a richer client experience but still have a web "enabled" application.

-Peter
  #5 (permalink)  
Old April 26th, 2005, 04:17 AM
Friend of Wrox
Points: 410, Level: 7
Points: 410, Level: 7 Points: 410, Level: 7 Points: 410, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2004
Location: New Delhi, India.
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anubhav.kumar
Default

Hi to all.

I my opinion, the data adapter / datset combinantion supports what we call disconnected database model. This model is suitable for distributed databses where not only database is fragmented horizontally or vertivally but the no. of users of application are variable at a given point of time. Although concurrency is a major issue and cannot be ignored.

The second model ( command / connection) is suitable for either desktop applications where database and front end are on same system or it is suitable for a limited multiuser windows application.

As far as asp.net is concencerned, i do support the notion of stateless nature of pages and obvious use of command/connection objects directly.

Any commnets?

Cheers.

Anubhav Kumar
  #6 (permalink)  
Old April 26th, 2005, 05:00 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Thanks for the replies Planoie and Anubhav.

I think, winforms are similar to active x controls on browsers (managed active x control ?). I fear it is not compatible to browsers other than IE. Is it correct ?
  #7 (permalink)  
Old April 26th, 2005, 05:02 AM
Friend of Wrox
 
Join Date: Apr 2005
Location: Cochin, , India.
Posts: 186
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Madhu,

If Feel you should spent some time on .NET Data Access Architecture Guide
(http://msdn.microsoft.com/library/de.../html/daag.asp)

and also think about whether use Microsoft Data Access Application Block for .NET, because it will reduce a good no of Lines of code.



  #8 (permalink)  
Old May 1st, 2005, 11:24 PM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Thanks Prashant for this great link. It gave me a lot of ideas.
 


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
Difference between ADO and ADO.NET rakeshclose2u ADO.NET 2 April 23rd, 2007 03:57 AM
ADO AND ADO.NET royalsurej ADO.NET 1 November 8th, 2004 08:28 AM
How can connect VB.Net with ADO.Net? arvind_pathak VS.NET 2002/2003 1 November 6th, 2003 09:22 AM
ADO.NET with ASP.NET stu9820 ADO.NET 5 September 2nd, 2003 11:47 AM
MSDE and SQL CE (using VB.NET and ADO.NET) LEGS ADO.NET 0 July 12th, 2003 11:27 AM



All times are GMT -4. The time now is 10:09 PM.


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