opening/closing database connection inside repeater

sergiu

New Member
I have a repeater which grabs data from multiple tables in each iteration. Right now i'm opening the connection as soon as i enter the OnItemDataBound event and closing it before the event is complete. That means the connections is opened and closed more than 1000 times in my case. Is this the right way to do this? are there any other ways? my code basically looks like this\[code\] Protected Sub myRepeater_OnItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Try mycon.open() Dim RowView As DataRowView = e.Item.DataItem //fetch data from 5 different tables using the data from the datasource (dataset) mycon.close() Catch ex As Exception End TryEnd Sub\[/code\]
 
Back
Top