You did not indicate what kind of processes (CalculateValue1...10 and
UpdateValues) inside the loop are, are they time-consuming processes? If
they are, you'd better not put these processes inside a DataReader's Read()
loop. I'd recommend you re-structure it this way:
OpenConnection
Open DataReader
Read all data from DB into a data structure, such as array, list or
collection
Close Reader
Close Connection
Loop through the Data Structure
Call CalculateValue1
...
UpdateValues
End Loop
With this structure, your app only open one connection when needed and close
it whenever the access to DB is done, as opposed to your original structure,
where a connection is kept open during lengthy processing and your app at
least need two connections to loop through.
[quoted text, click to view] "Bonato Pierantonio" <pbonato@interfree.it> wrote in message
news:u7xEQaoDHHA.4256@TK2MSFTNGP04.phx.gbl...
> Hi all,
> I have a problem that I cannot resolve. I try yo explaim my scenario:
> There is an application deveoped in VB.NET
> I have a cycle the LOOP on a DataReader inside the cycle there is some
> like this
> OpenConnection
> do while Dr.Read <-- for several record, I suppose some like 100/150
> call CalculateValue1
> call CalculateValue2
> ...
> call CalculateValue10
>
> call UpdateValues
> LOOP
> Close Connection
>
> Where the function CalculateValueX is some like this
> Open Connection
> Execute Command
> Close Connection
>
> and similar the UpdateValues
> OpenConnection
> execute cmd "UPDATE (a,b,c) VALUES (1,2,3)
> CloseConnection
>
> The problem is that 1 times each 3 or 4 during the UPDATE command the Sql
> give me an error TIMEOUT EXPIRED EXECUTING COMMAND
>
> Only for test I try to use a different connectionstring on the UPDATE
> COMMAND (so it doesn't use the Pool Connection) and it seems to work bette
> use thir. But I cannot this connectionString in the real deployment.
>
> Please someone can help me???
>
>