Visual Basic .NET » ASP.NET General Discussion
DataSet and web -- Falcon --


Hello All,
I have developed an N-Tear based Web-Application.
For one of the feature I have to define a DataSet Object in the Code behind of a page containing a grid component to present it. That DataSet will be initialize in the DAL.
The problem is that I don't know how to define this DataSet, as a member of the ASP code behind page, or as a n Object in the session.I need to let the user access to the dataset and let the dataset to be valid long as the user is logged and it that Page. The thing is to let the user make all its work on the dataset and when he hits Update,
then to take the DataSet and bringing it to the DAL for Updating.
What do you say?

-- alex --


You may want to try using the data table object instead and store the table in the cache for access. Create the aspx page and give the datagird the ID of MyDataGrid then in the code behind add. You can store the datatable in th cahce and access it from there.....

Let me know if this works for what you are trying to accomplish.

Imports System Imports System.Data Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls

'then declare the data table object Protected WithEvents myDataTable As DataTable

'Map the web form controls Protected WithEvents MyDataGrid As DataGrid Protected WithEvents eventsList As Label

Private Sub BindMyDataGrid()

'Get the DataSet
MakeMyDataTable()

'Set the DataGrid.DataSource properties
productGrid.DataSource = myDataTable

'Bind the DataGrid
productGrid.DataBind()
End Sub
Private Sub MakeMyDataTable()
'''' instantiate the DataSet as follow unless you already have access to the Data Set
'Define the SQL command and connection string Dim mySqlStmt As String = "SELECT * FROM Customers"
Dim myConString As String =
"server=(local);database=Northwind;uid=sa;pwd=;"
'Construct a new SqlDataAdapter Dim myDataAdapter As New SqlDataAdapter()
'Construct the SqlCommand that will be the data adapter's SelectCommand Dim myConnection As New SqlConnection(myConString)
Dim myCommand As New SqlCommand(mySqlStmt, myConnection)
'Set the SelectCommand property myDataAdapter.SelectCommand = myCommand myDataAdapter.Fill(myDataSet, "Customers")
myDataTable = CType(Cache.Get("myDataTable"), DataTable)
'If myDataTable is not in the cache, create it
If myDataTable Is Nothing Then
myDataTable = ds.Tables("Customers")
Cache.Insert("myDataTable", myDataTable)
end if

End Sub
Alexander Higgins
Http://www.signcreationsllc.com 


[Submit Comment]Home