Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 23rd, 2005, 03:39 AM
Friend of Wrox
 
Join Date: Oct 2003
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 ?
 
Old April 23rd, 2005, 03:03 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
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
 
Old April 25th, 2005, 03:25 AM
Friend of Wrox
 
Join Date: Oct 2003
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 ?
 
Old April 25th, 2005, 07:58 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
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
 
Old April 26th, 2005, 04:17 AM
Friend of Wrox
 
Join Date: Oct 2004
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
 
Old April 26th, 2005, 05:00 AM
Friend of Wrox
 
Join Date: Oct 2003
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 ?
 
Old April 26th, 2005, 05:02 AM
Friend of Wrox
 
Join Date: Apr 2005
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.



 
Old May 1st, 2005, 11:24 PM
Friend of Wrox
 
Join Date: Oct 2003
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.





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





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