L
Lloyd Dupont
I just watch an overview of ADO.NET 2 on MSDN TV.
In that demo the SqlDataAdapter featured a batch mode where you cold submit
update of many line with one query.
(instead of the line by line update as now)
I thought it was a great feature.
Now in my own PocketPC database application (www.ihookdb.com I have my
own "data access layer" and I thought it would be nice to use batch update
too. (and because it's my code I could do it today
And there a few question came to my mind (on about how to do that)
1. I was thinking, oh well man, it's simple, just queue the query with ';'
in the middle.
but there is a problem
if I write
UPDATE MyTable (field1, field2) VALUES (@field1_1, @field2_1) WHERE
ID=@field3_1; UPDATE MyTable (field1, field2) VALUES (@field1_2, @field2_2)
WHERE ID=@field3_2;..... N times (where N is my batch size)
(notice I write @field_1 for 1st query, @field1_2 for the second, etc ...)
but what if I use a batch size of 100 and they submit only 3 line changes ?
should I create the query depending on the number of changes ?
how to do that cleanly ?
2. but there is worst !
lest say I do an INSERT with an ID Identity column, I should have a SELECT
@@IDENTITY after my insert. but what happened if I do many insert at a time
?!....
Any SQL Admin to rescue me ?!!
In that demo the SqlDataAdapter featured a batch mode where you cold submit
update of many line with one query.
(instead of the line by line update as now)
I thought it was a great feature.
Now in my own PocketPC database application (www.ihookdb.com I have my
own "data access layer" and I thought it would be nice to use batch update
too. (and because it's my code I could do it today
And there a few question came to my mind (on about how to do that)
1. I was thinking, oh well man, it's simple, just queue the query with ';'
in the middle.
but there is a problem
if I write
UPDATE MyTable (field1, field2) VALUES (@field1_1, @field2_1) WHERE
ID=@field3_1; UPDATE MyTable (field1, field2) VALUES (@field1_2, @field2_2)
WHERE ID=@field3_2;..... N times (where N is my batch size)
(notice I write @field_1 for 1st query, @field1_2 for the second, etc ...)
but what if I use a batch size of 100 and they submit only 3 line changes ?
should I create the query depending on the number of changes ?
how to do that cleanly ?
2. but there is worst !
lest say I do an INSERT with an ID Identity column, I should have a SELECT
@@IDENTITY after my insert. but what happened if I do many insert at a time
?!....
Any SQL Admin to rescue me ?!!