VB.Net-FORM - Multiple Connections to Sql Server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abev
    New Member
    • Jan 2008
    • 22

    #1

    VB.Net-FORM - Multiple Connections to Sql Server

    I have a table adapter with multiple queries. I have code that calls many of these queries (stored procedures) within a For...Next loop. It reuses the declared object many times.

    Should I be releasing the object somehow between loops? I feel like the code is excessively slow. Each time a query is called, am I creating a new connection to SQL server or does it open, close, reuse?

    Here is a sample. As you can see I reuse oAggregateGoal many times. oAggregateGoal is dimensioned this way:
    Code:
    Dim oAggregateGoal As New Aggregate_GoalDataSetTableAdapters.PlayByPlayTableAdapter
    Code:
    For c As Integer = 0 To 1
    curSHOTS(c) = oAggregateGoal.ag_GetShotCount(iGame, sStrength(b), iPeriod(a), sTeam(c))
    curGOALS(c) = oAggregateGoal.ag_GetGOALCount(iGame, sStrength(b), iPeriod(a), sTeam(c))
    curMiss(c) = oAggregateGoal.ag_GetMISSCount(iGame, sStrength(b), iPeriod(a), sTeam(c))
    curTake(c) = oAggregateGoal.ag_GetTAKECount(iGame, sStrength(b), iPeriod(a), sTeam(c))
    curGive(c) = oAggregateGoal.ag_GetGIVECount(iGame, sStrength(b), iPeriod(a), sTeam(c))
    curBlock(c) = oAggregateGoal.ag_GetBLOCKCount(iGame, sStrength(b), iPeriod(a), sTeam(c))
    curFace(c) = oAggregateGoal.ag_GetFaceOffWinCount(iGame, sStrength(b), iPeriod(a), sTeam(c))
    curStopGoalie(c) = oAggregateGoal.ag_GetStopGoalieCount(iGame, sStrength(b), iPeriod(a), sTeam(c))
    curStopOther(c) = oAggregateGoal.ag_GetStopOtherCount(iGame, sStrength(b), iPeriod(a), sTeam(c))
    curHit(c) = oAggregateGoal.ag_GetHitCount(iGame, sStrength(b), iPeriod(a), sTeam(c))
    curPENL(c) = oAggregateGoal.ag_GetPENLCount(iGame, sStrength(b), iPeriod(a), sTeam(c))
    curPENLMin(c) = oAggregateGoal.ag_GetPENLSUM(iGame, sStrength(b), iPeriod(a), sTeam(c))
    Next
Working...