song2siren
Programmer
Hello
I use the following function in my code behind when the page loads to populate a listbox from values in a SQL table:
Public Function GetSubjects() As DataView
cmdSql = New SqlCommand("Pubs_getSubjects", myConnection)
cmdSql.CommandType = CommandType.StoredProcedure
myConnection.Open()
frmSubjects.DataSource = cmdSql.ExecuteReader()
frmSubjects.DataBind()
'insert blank choice on top of the subjects listbox.
frmSubjects.Items.Insert(0, New ListItem("Select Subject...", [String].Empty))
myConnection.Close()
End Function
However, I just need some guidance on how I would cache things like this rather than open a connection to the database each time the page is opened. Any suggestions would be very much appreciated.
Thanks
I use the following function in my code behind when the page loads to populate a listbox from values in a SQL table:
Public Function GetSubjects() As DataView
cmdSql = New SqlCommand("Pubs_getSubjects", myConnection)
cmdSql.CommandType = CommandType.StoredProcedure
myConnection.Open()
frmSubjects.DataSource = cmdSql.ExecuteReader()
frmSubjects.DataBind()
'insert blank choice on top of the subjects listbox.
frmSubjects.Items.Insert(0, New ListItem("Select Subject...", [String].Empty))
myConnection.Close()
End Function
However, I just need some guidance on how I would cache things like this rather than open a connection to the database each time the page is opened. Any suggestions would be very much appreciated.
Thanks