.NETGURU
Updating a database from ASP.NET
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngdata' list.


Hector Caban
When programming in asp, sometimes I would update a field=20
with out using SQL. For Example :

If Request.QueryString("chkActive") =3D "1" Then
rs("Active") =3D True
Else
rs("Active") =3D False
End If

rs.update()
rs.close()

Can I do the samething with ADO.NET or do I have to always=20
use execute a SQL statement ?

Thanks for your help

Hector Caban=20
A+, Net+, MCP+SB, MCSA, MCSE, MCT, CCNA

Reply to this message...
 
    
Andy Smith
while you _could_ do the same thing with a dataset, adapter, select =
command, update command, and connection, I think it wouldn't be very =
efficient compared to just an update command and connection.

steps for the dataset way:
1) make a connection to your database
2) make an adapter
3) make the select command and attach to the adapter and connection
4) make the update command and attach to the adapter and connection
5) call Fill on the adapter, giving a dataset
6) change your field in the dataset
7) call update on the adapter, giving the dataset

of course, steps 1 thru 4 can be done with a wizard in vstudio

but I think it's easier to do this:
1) make a connection to your database
2) make the update command and attach to the connection
3) set the parameters with the new values
4) call the command

1 and 2 can be done with a wizard in vstudio

the first one makes more sense in a windows.forms application, and the =
second makes more sense in a web application

__
Andy Smith
Chief Code Monkey

[Original message clipped]

Reply to this message...
 
    
Andrew Munro
although the vs studio wizard makes it easy for the developer to generate db
driven web apps the amount of extra code generated is rather heavy. Its
much easier to code your own data adapters and use stored procedures on the
DB side for the commands. This inturn allows any data retrieval to be
modified via the stored procedure without having to modify any of the code.
Maintenance of the app is easier

-----Original Message-----
From: Andy Smith [mailto:Click here to reveal e-mail address]
Sent: 17 June 2002 19:20
To: aspngdata
Subject: [aspngdata] RE: Updating a database from ASP.NET

while you _could_ do the same thing with a dataset, adapter, select command,
update command, and connection, I think it wouldn't be very efficient
compared to just an update command and connection.

steps for the dataset way:
1) make a connection to your database
2) make an adapter
3) make the select command and attach to the adapter and connection
4) make the update command and attach to the adapter and connection
5) call Fill on the adapter, giving a dataset
6) change your field in the dataset
7) call update on the adapter, giving the dataset

of course, steps 1 thru 4 can be done with a wizard in vstudio

but I think it's easier to do this:
1) make a connection to your database
2) make the update command and attach to the connection
3) set the parameters with the new values
4) call the command

1 and 2 can be done with a wizard in vstudio

the first one makes more sense in a windows.forms application, and the
second makes more sense in a web application

__
Andy Smith
Chief Code Monkey

[Original message clipped]

| [aspngdata] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngdata.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
    
Hector Caban
Thanks for all the help. Unusually I don't like to use wizards, just
because I like to take a control of my code. Now I like to use stored
procedures the only problem is that I am using MS Access as my backend.

-----Original Message-----
From: Andrew Munro [mailto:Click here to reveal e-mail address]=20
Sent: Tuesday, June 18, 2002 4:31 AM
To: aspngdata
Subject: [aspngdata] RE: Updating a database from ASP.NET

although the vs studio wizard makes it easy for the developer to
generate db driven web apps the amount of extra code generated is
rather heavy. Its much easier to code your own data adapters and use
stored procedures on the DB side for the commands. This inturn allows
any data retrieval to be modified via the stored procedure without
having to modify any of the code. Maintenance of the app is easier

-----Original Message-----
From: Andy Smith [mailto:Click here to reveal e-mail address]
Sent: 17 June 2002 19:20
To: aspngdata
Subject: [aspngdata] RE: Updating a database from ASP.NET

while you _could_ do the same thing with a dataset, adapter, select
command, update command, and connection, I think it wouldn't be very
efficient compared to just an update command and connection.

steps for the dataset way:
1) make a connection to your database
2) make an adapter
3) make the select command and attach to the adapter and connection
4) make the update command and attach to the adapter and connection
5) call Fill on the adapter, giving a dataset
6) change your field in the dataset
7) call update on the adapter, giving the dataset

of course, steps 1 thru 4 can be done with a wizard in vstudio

but I think it's easier to do this:
1) make a connection to your database
2) make the update command and attach to the connection
3) set the parameters with the new values
4) call the command

1 and 2 can be done with a wizard in vstudio

the first one makes more sense in a windows.forms application, and the
second makes more sense in a web application

__
Andy Smith
Chief Code Monkey

[Original message clipped]

| [aspngdata] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.asplists.com/asplists/aspngdata.asp =3D JOIN/QUIT=20
| http://www.asplists.com/search =3D SEARCH Archives

| [aspngdata] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.asplists.com/asplists/aspngdata.asp =3D JOIN/QUIT=20
| http://www.asplists.com/search =3D SEARCH Archives

Reply to this message...
 
    
Andy Smith
The adapter-creation wizard is perfectly capable of both creating new =
stored procedures and using existing sprocs.
nowhere in my steps did I say that sql statements are to be used instead =
of sprocs.

As far as "being much easier to code your own data adapters"... I don't =
know what your typing speed is... but I'm willing to be it easier and =
faster to drag an icon, click a few buttons, and select a few dropdowns, =
than it is to type out 20+ lines of code.

__
Andy Smith
Chief Code Monkey

[Original message clipped]

Reply to this message...
 
 




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification