J
Jason
I am having problems understanding how to access a datasource only
once, fill a single dataset, and then reference that dataset multiple
times through different user controls(ascx) found on the same page.
My main page(aspx) contains multiple user controls. The main page also
contains a publicly declared dataset. At the first instance of needing
data I call (from an ascx) a function that fills the dataset and then
returns it to the calling user control. Every instance after that I
would like to call a function that just returns the data that has
already been populated in the dataset. But the dataset is empty. I
have to go back to the datasource everytime. How can I make the
dataset persistent without storing it in something that will use up
resources like a session variable?
Here are some examples of the code in question:
'(Main.ASPX.vb) DsAdmin_ is publicly defined at the top of the class.
Function CreateDataSource(ByVal strdTable As String, ByVal strSQL As
String) As DataSet
Dim ErrMsg As String = Nothing
Try
objData.OpenConn()
Dim objCmd As New SqlClient.SqlDataAdapter(strSQL,
objData.Conn)
objCmd.Fill(DsAdmin_, strdTable)
CreateDataSource = DsAdmin_
Catch exp As Exception
ErrMsg = Err.Description & Err.Source
End Try
objData.CloseConn(
End Function
Public Function GetData() As DataSet
GetData = DsAdmin_
End Function
'code snippets from UserControl1.ascx.vb: This control returns data.
DSAdmin_ is locally defined in a sub of this control.
Public Main As New MyProject.Main
DsAdmin_ = Main.CreateDataSource("dtblUser", "Execute
sp_Admin_GetUserDetails " & (Request("id"))
'code snippets from UserControl2.ascx.vb: This dataset is empty.
DSAdmin_ is locally defined in a sub of this control.
Public Main As New MyProject.Main
DsAdmin_ = Main.GetData()
Any help would be GREATLY Appreciated!!!
once, fill a single dataset, and then reference that dataset multiple
times through different user controls(ascx) found on the same page.
My main page(aspx) contains multiple user controls. The main page also
contains a publicly declared dataset. At the first instance of needing
data I call (from an ascx) a function that fills the dataset and then
returns it to the calling user control. Every instance after that I
would like to call a function that just returns the data that has
already been populated in the dataset. But the dataset is empty. I
have to go back to the datasource everytime. How can I make the
dataset persistent without storing it in something that will use up
resources like a session variable?
Here are some examples of the code in question:
'(Main.ASPX.vb) DsAdmin_ is publicly defined at the top of the class.
Function CreateDataSource(ByVal strdTable As String, ByVal strSQL As
String) As DataSet
Dim ErrMsg As String = Nothing
Try
objData.OpenConn()
Dim objCmd As New SqlClient.SqlDataAdapter(strSQL,
objData.Conn)
objCmd.Fill(DsAdmin_, strdTable)
CreateDataSource = DsAdmin_
Catch exp As Exception
ErrMsg = Err.Description & Err.Source
End Try
objData.CloseConn(
End Function
Public Function GetData() As DataSet
GetData = DsAdmin_
End Function
'code snippets from UserControl1.ascx.vb: This control returns data.
DSAdmin_ is locally defined in a sub of this control.
Public Main As New MyProject.Main
DsAdmin_ = Main.CreateDataSource("dtblUser", "Execute
sp_Admin_GetUserDetails " & (Request("id"))
'code snippets from UserControl2.ascx.vb: This dataset is empty.
DSAdmin_ is locally defined in a sub of this control.
Public Main As New MyProject.Main
DsAdmin_ = Main.GetData()
Any help would be GREATLY Appreciated!!!