B
Bob Day
Using VS 2003, VB.net SQL MSDE...
The code below fails every time. Essentially, is it rapidly adding 1 row
and then updating that row to the datasource and then repeating 200 times.
It fails on the .UPDATE after about 73 UPDATES with the error message:
"A first chance exception of type 'System.InvalidOperationException'
occurred in system.data.dll.
Additional Information: Timeout expired. The timeout period elapsed prior
to obtaining a connection from the pool. This may have occurred because all
pooled connections were in use and max pool size was reached."
If you UPDATE 50 rows at a time, instead of one, you do not get this error
message. Having researched help, this error implies I am opening a
connection that I am not closing. However, everything below is created in
component designer, which should be handling this automatically.
1) Why is this failing?
2) How do I fix it?
Code Snippet:
' DIM Rows_Updated - rows updated by DataAdapter
Dim Rows_Updated As Integer = -1
Dim count As Integer = -1
' instantiate dataset
Dim DS As New DS_Caller_Base
' clear DataTable rows
ds.PINS.Rows.Clear()
' instantiate a DR to add
Dim DR_To_Add As DS_Caller_Base.PINSRow
For count = 0 To 200
' set DR row = to dataset we are working with
DR_To_Add = DS.PINS.NewPINSRow
With DR_To_Add
' set foreign key value (only needed for new row)
.fld_FK_Customer_Table_ID = 6
.fld_IX_PIN = CStr(count)
End With
' add new empty row to dataset
DS.PINS.AddPINSRow(DR_To_Add)
' cd is an instantiation of Component Designer
Rows_Updated = CD.DA_tblPINS.Update(DS, DS.PINS.TableName)
Next
Thanks!
Bob Day
The code below fails every time. Essentially, is it rapidly adding 1 row
and then updating that row to the datasource and then repeating 200 times.
It fails on the .UPDATE after about 73 UPDATES with the error message:
"A first chance exception of type 'System.InvalidOperationException'
occurred in system.data.dll.
Additional Information: Timeout expired. The timeout period elapsed prior
to obtaining a connection from the pool. This may have occurred because all
pooled connections were in use and max pool size was reached."
If you UPDATE 50 rows at a time, instead of one, you do not get this error
message. Having researched help, this error implies I am opening a
connection that I am not closing. However, everything below is created in
component designer, which should be handling this automatically.
1) Why is this failing?
2) How do I fix it?
Code Snippet:
' DIM Rows_Updated - rows updated by DataAdapter
Dim Rows_Updated As Integer = -1
Dim count As Integer = -1
' instantiate dataset
Dim DS As New DS_Caller_Base
' clear DataTable rows
ds.PINS.Rows.Clear()
' instantiate a DR to add
Dim DR_To_Add As DS_Caller_Base.PINSRow
For count = 0 To 200
' set DR row = to dataset we are working with
DR_To_Add = DS.PINS.NewPINSRow
With DR_To_Add
' set foreign key value (only needed for new row)
.fld_FK_Customer_Table_ID = 6
.fld_IX_PIN = CStr(count)
End With
' add new empty row to dataset
DS.PINS.AddPINSRow(DR_To_Add)
' cd is an instantiation of Component Designer
Rows_Updated = CD.DA_tblPINS.Update(DS, DS.PINS.TableName)
Next
Thanks!
Bob Day