473,473 Members | 1,607 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

sql: multiple row update

Greetings,

Fairly new to c# and Im looking for pointers on a few topics:

Im curious as to general methods to update multiple rows in a database.
Currently Im thinking of just allowing a user to update one row of data at a
time and designing/building textboxes to allow them to enter this data. I
would then use a method to insert this data. (sqlCommand)

Is there a more efficient method of updating 10 rows of data at a time? Such
that if I display the data in lets say a datagrid that they can edit the data
and I can programatically add this to the DB?

Along the same lines , what methods in general would be available to
distinguish between data being updated as compared to inserted? Any methods
that aid in this step. In my past programming , this wouldve fallen on the
programmer to decide(logic) if the row was present in the DB and to update
if not to insert.

As a side note: Im finding this site/newsgroup to a huge resource.

Thanks much,

Christopher



Nov 16 '05 #1
2 3683
It used to be that I would recommend sending a large group of Stored Proc
calls to SQL Server in a single "batch" but the possibility of SQL Injection
attacks has brought those days to an end.

I would suggest that you present the U/I in any way that you see fit.
However, when it comes to sending updates to SQL, you are well served by
calling a stored proc that will decide if the change is an insert or an
update, and that you call one of them at a time (SqlCommand) and that you
use the parameter objects to avoid SQL Injection attacks.

Security trumps speed on this one, although the speed difference is tiny,
especially for most interactive applications.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Christopher" <Ch*********@discussions.microsoft.com> wrote in message
news:68**********************************@microsof t.com...
Greetings,

Fairly new to c# and Im looking for pointers on a few topics:

Im curious as to general methods to update multiple rows in a database.
Currently Im thinking of just allowing a user to update one row of data at a time and designing/building textboxes to allow them to enter this data. I
would then use a method to insert this data. (sqlCommand)

Is there a more efficient method of updating 10 rows of data at a time? Such that if I display the data in lets say a datagrid that they can edit the data and I can programatically add this to the DB?

Along the same lines , what methods in general would be available to
distinguish between data being updated as compared to inserted? Any methods that aid in this step. In my past programming , this wouldve fallen on the
programmer to decide(logic) if the row was present in the DB and to update if not to insert.

As a side note: Im finding this site/newsgroup to a huge resource.

Thanks much,

Christopher


Nov 16 '05 #2

Christopher wrote:
Greetings,

Fairly new to c# and Im looking for pointers on a few topics:

Im curious as to general methods to update multiple rows in a database. Currently Im thinking of just allowing a user to update one row of data at a time and designing/building textboxes to allow them to enter this data. I would then use a method to insert this data. (sqlCommand)

Is there a more efficient method of updating 10 rows of data at a time? Such that if I display the data in lets say a datagrid that they can edit the data and I can programatically add this to the DB?


Not sure I follow. You could have a Save button and
you simply build the right UPDATE statement, with a
WHERE clause that matches all rows you wish to update.
Is that what you mean?

Jose Solorzano

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rima | last post by:
I have the following two tables : table a (commit_id, capital_market_id, chg_lst_date ) table b (b_seq_id,
7
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a...
8
by: Lauren Quantrell | last post by:
In VBA, I constructed the following to update all records in tblmyTable with each records in tblmyTableTEMP having the same UniqueID: UPDATE tblMyTable RIGHT JOIN tblMyTableTEMP ON...
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
3
by: -Michelle- | last post by:
Hi Using A2003 on XP I am wondering from the MVP's and others, what is the most efficient way (in terms of time to process) of updating data in a table, using the docmd.RunSQL or Recordset ...
3
by: spartacus | last post by:
Hi, Does SQL support update to multiple rows where values coming from a sub-query? e.g insert into TABLE1 select column1, column2, column3 from TABLE2
138
by: Ian Boyd | last post by:
i've been thrown into a pit with DB2 and have to start writing things such as tables, indexes, stored procedures, triggers, etc. The online reference is only so helpful. The two pdf manuals are...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
2
by: Doug | last post by:
Hi, I wanted to start a general discussion more for getting some thoughts on what other people think/practice out there just to see how far (if at all) I'm off base on my own thoughts. My...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.