Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: CheckBoxList update


Message #1 by "Hovik Melkomian" <melvik@b...> on Sun, 9 Mar 2003 04:03:14 +0430
Paul, I of course don't know what you're working on but the description
you've given may not rule out stored procedures.

As you must know given the nature of your project, SQL Server 2000 and
Oracle (and probably other databases too) offer tools for examining
meta-data in the database.  .NET includes an amazing array of features 
for
using this information and for creating code by reflection.  Given your
challenge, some developers would be inclined to use these features to 
create
- once, upon installation - code and stored procedures that subsequently
provide efficient and secure database interaction to the application.

If you haven't ruled this out, you might want to look around on the Web 
for
a free tool called LLBLGen, an application which examines a SQL Server
database and creates a full set of stored procedures for the database, 
as
well as complete .NET classes for the application's data layer, all 
based on
the database's metadata.  The LLBLGen application is available WITH FULL
SOURCE CODE, for free, and perhaps can give you ideas for improving your
project.

HTH

-----Original Message-----
From: Paul Riley [mailto:rilez@t...]
Sent: Sunday, March 09, 2003 7:54 AM
To: ASPX_Professional
Subject: [aspx_professional] RE: CheckBoxList update


Sorry Chris you're right wrt SQL server and so in this case yes. However 
I
do a lot of work with various data types (am currently creating a system 
to
web enable any database system) so Stored procedures are pretty useless 
to
me 90% of the time. Stored procedures are a luxury that sometimes are
impossible to introduce.

Just wanted to set the record straight - sorry if I mis-directed you 
Hovik

Paul

-----Original Message-----
From: Chris [mailto:wrox@d...]
Sent: 08 March 2003 19:09
To: ASPX_Professional
Subject: [aspx_professional] RE: CheckBoxList update



Hovik, with all respect to Paul Riley his suggestion is *NOT* "the best 
way"
to use your database.  While use of dynamic SQL strings is found 
throughout
most books and examples, it is used there not because it's the right way 
but
because it is easier for the authors to illustrate all aspects of a 
topic in
one code file, and therefore easier for their readers to learn the 
topic.

Dynamic SQL is usually among the WORST ways to communicate with a 
database.
It has significant costs in performance, security risk, ease of data
management in the enterprise, and application development and 
maintenance.

The word from Microsoft and virtually all skilled developers is crystal
clear:  use stored procedures, accessed through a purpose-built data 
layer
of generalized and specific routines for building parameter sets, 
calling
stored procedures and capturing the results they return.  Since 
Microsoft
gives away, for free, its Data Access Application Block code in which 
most
of the hard work is done, virtually no application or developer can be
excused for not doing data access the right way.

The "right way" means that you should create a stored procedure in your
database that will accept a bit-type parameter from your checkbox and 
write
the value into your database.  You should use the .NET SQLParameter 
class to
define a parameter object containing your checkbox's value, open a 
database
connection, pass the parameter and the name of your stored procedure 
into
the appropriate class (probably
ExecuteNonQuery) of the Data Access Application Block, 'listen' for any
exception or error code that might be returned, and close the database
connection.

If you're interested in writing less code to produce a faster, more 
secure
application that's easier to maintain, then take the time to learn this
approach to efficiently using data stores.  If you're not interested in
those things, go ahead and create dynamic SQL strings.

How can you learn the "right" way?  Unfortunately, as I said most books 
on
data access will show you the wrong way.  Two Wrox books - SQL Server 
2000
Database Design, and Visual Basic .NET and SQL Server 2000, will help
improve your understanding of the right way because at least *in
part* they describe the reasons for using proper data access techniques 
and
show some of the methods.  I don't know of any excellent book that 
teaches
all aspects of the proper use of designing and using SQL Server data 
stores
- WROX ARE YOU LISTENING? - and I have nearly 100 recent books on .NET 
and
databases stacked around me here.  Look on the Microsoft MSDN web site 
for
the "Data Access Application Block" and related articles and code.  The
following sites may be useful as you learn more.

http://www.sswug.org/

http://www.sqlteam.com/

http://www.only4gurus.com/v2/index.asp

HTH


-----Original Message-----
From: Paul Riley [mailto:rilez@t...]
Sent: Saturday, March 08, 2003 9:23 AM
To: ASPX_Professional
Subject: [aspx_professional] RE: CheckBoxList update


The best way of doing it is to build an update SQL string and then use 
that.
Then you just need one database use per record. If your still not sure 
paste
you code :)

hth

-----Original Message-----
From: Hovik Melkomian [mailto:melvik@b...]
Sent: 09 March 2003 00:41
To: ASPX_Professional
Subject: [aspx_professional] RE: CheckBoxList update


tnx for response:
I knew it before, my question is that how should I updated it?!?!
Clearly:
I got a dataset from Database & use it to fill CheckBoxList texts & 
values.
Then I have to update the related table with new items. what should I 
do?!
if I make a loop & read from top to end its ok, but it'll have many
connection with database in every loop!  I dont think any stuped person 
does
it!!! SO I asked for a good way & professional.

Always,
Hovik.

----- Original Message -----
From: "Chris" <wrox@d...>
To: "ASPX_Professional" <aspx_professional@p...>
Sent: Saturday, March 08, 2003 5:39 PM
Subject: [aspx_professional] RE: CheckBoxList update



Hovik,

MyDatabaseFieldValue =3D MyCheckBox.Checked

The Checked property of the checkbox control is true when the checkbox 
is
checked.

HTH

-----Original Message-----
From: Hovik Melkomian [mailto:melvik@b...]
Sent: Saturday, March 08, 2003 6:33 PM
To: ASPX_Professional
Subject: [aspx_professional] CheckBoxList update


I've gotten so many helps from friends over here, so I try it again:

I use C#.net, DataReader & MS-SQL 2000 (recordset) to databind & fill a
CheckBoxList. Its fine but NOW I dont know how should I update checked &
unchecked boxes in my table in Database?!

I hope to hear from u ASAP.

Thanks in advance,
Hovik.


---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 




---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 















  Return to Index