This code is a mess. It sounds like you're doing double the work and adding
enormous complexity to something as simple as updating a number of customer
records. You're executing a large number of SELECT statements one at a time
to fetch data that you plan to update in any case. Doing a batch update with
a DataAdapter actually performs multiple INSERTs or UPDATEs in a loop.
Now, depending on whether you're doing an INSERT or an UPDATE, each record
could be handled completely in your loop using a simple INSERT or UPDATE
statement. For example:
INSERT INTO Database1.dbo.someTable (CustID, ColumnA, ColumnB)
SELECT t1.SomeID1. 'Column A Value', 'Column B Value'
FROM Database1.dbo.someOtherTable t1
- or -
UPDATE Database1.dbo.someTable
SET ColumnA = 'ColumnA Value', ColumnB = 'Column B Value'
WHERE CustID = @CustID
A Stored Procedure would be more efficient than building a string. And
finally, your usage of GetType() to find out if a DataReader column value is
null is superfluous. When you reference the column value without a type, it
is of type object, and if it is null, it is null. Example:
if (Reader1.IsDbNull(0)) ...

Signature
HTH,
Kevin Spencer
Microsoft MVP
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
> // Set up command for reuse in loop just change the customer id
> SqlConn1.Cmd = new SqlCommand();
[quoted text clipped - 70 lines]
> Thanks
> DaveP
DaveP - 03 Oct 2007 21:42 GMT
again code is sample....
1 datatable not ready for inserts it is missing key columns
i require from the database.
2. i am asking if there is a way to link a Array or a this table to
retrieve all values required before i do a batch update..
3 ..i dont like the code either....again a example of a loop
making calls to the database ....
if i can bind a array or a offline table to the database
i can make a single call....finialize this offline table
and write complete rows back to the database
....
what i did yesterday is just get the parsed data to a temp table on the
server and run a proc to get the rest of the values needed....
again..
looking for other options and experience from others
the final decision is mine how i accomplish a task
DaveP
> This code is a mess. It sounds like you're doing double the work and
> adding enormous complexity to something as simple as updating a number of
[quoted text clipped - 100 lines]
>> Thanks
>> DaveP