473,387 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

OOP in ASP .Net Pages

RSH
I am struggling with a concept I'm not really finding a lot of in depth
articles on but Im sure others have had similar issues.

What is the best practice when it comes to persisting custom created objects
during a user's session?

I have created several objects that when run with an Out of Process session
state they cause the dreaded "Unable to serialize the session state. Please
note that non-serializable objects or MarshalByRef objects are not permitted
when session state mode is 'StateServer' or 'SQLServer'. " exception.

In the past I have created a base object that contained all of the
serializable properties, then create a concrete class underneath and
basically stripped the base class off and saved it in a session variable and
then "bolted" it back up when needed on other pages (.net 1.1). But now
that I am at the point where I need to develop an application I am wondering
how to deal with custom objects and persisting them properly.

Im struggling using OOP techniques for the web. How are other people
handling these techniques?

This is an example of the class that wont serialize, but I need to reference
it throughout the user's session:

Thanks,
Ron
<Serializable()Public Class CompanyBase

#Region "Member Variables"

Private m_ID As System.Int32

Private m_OfficeID As System.String

Private m_CompanyID As System.String

Private m_AliasID As System.String

Private m_CompanyName As System.String

Private m_DataSource As DataSourceType

Private m_oData As BaseDataClass

#End Region

#Region "Member Properties"

Public Property ID() As System.Int32

Get

Return m_ID

End Get

Set(ByVal Value As System.Int32)

m_ID = Value

End Set

End Property

Public Property OfficeID() As System.String

Get

Return m_OfficeID

End Get

Set(ByVal Value As System.String)

m_OfficeID = Value

m_CompanyDataset.Tables(0).Rows(0).Item("OfficeID" ) = Value

End Set

End Property

Public Property CompanyID() As System.String

Get

Return m_CompanyID

End Get

Set(ByVal Value As System.String)

m_CompanyID = Value

End Set

End Property

Public Property AliasID() As System.String

Get

Return m_AliasID

End Get

Set(ByVal Value As System.String)

m_AliasID = Value

End Set

End Property

Public Property CompanyName() As System.String

Get

Return m_CompanyName

End Get

Set(ByVal Value As System.String)

m_CompanyName = Value

End Set

End Property

#End Region

#Region "Constructor"

Public Sub New()

End Sub

Public Sub New(ByVal companyID As String)

m_CompanyID = companyID

m_DataSource = DataSourceType.SQLServer

DataSourceBuilder()

End Sub

#End Region

#Region "Member Methods"

Private Sub DataSourceBuilder()

If m_DataSource = DataSourceType.XML Then

m_File = HttpContext.Current.Request.PhysicalApplicationPat h & Me.CompanyID
& "_Company.xml"

m_oData = DataFactory.GetDataClass(m_File, DataSourceType.XML)

m_oData.ConnectionString = m_File

m_oData.PrimaryKey = "ID"

ElseIf m_DataSource = DataSourceType.Access Then

m_File = HttpContext.Current.Request.PhysicalApplicationPat h & "Global.mdb"

m_oData = DataFactory.GetDataClass(m_File, DataSourceType.Access)

m_oData.ConnectionString = m_File

m_oData.PrimaryKey = "ID"

m_oData.SQLString = "select * from companies WHERE CompanyID = '" &
m_CompanyID & "'"

ElseIf m_DataSource = DataSourceType.SQLServer Then

m_oData = DataFactory.GetDataClass("Global", DataSourceType.SQLServer)

m_oData.SQLString = "select * from Global.dbo.companies WITH(NOLOCK) WHERE
CompanyID = '" & m_CompanyID & "'"

m_oData.PrimaryKey = "ID"

End If

m_CompanyDataset = m_oData.GetDataSet()

BindProperties()

End Sub

Private Sub BindProperties()

Dim oDr As DataRow

If Not CompanyID Is Nothing Then

If m_CompanyDataset.Tables(0).Rows.Count 0 Then

oDr = m_CompanyDataset.Tables(0).Rows(0)

ID = IIf(Not IsDBNull(oDr("ID")), oDr("ID"), Nothing)

OfficeID = IIf(Not IsDBNull(oDr("OfficeID")), oDr("OfficeID"), Nothing)

CompanyID = IIf(Not IsDBNull(oDr("CompanyID")), oDr("CompanyID"), Nothing)

AliasID = IIf(Not IsDBNull(oDr("AliasID")), oDr("AliasID"), Nothing)

CompanyName = IIf(Not IsDBNull(oDr("CompanyName")), oDr("CompanyName"),
Nothing)

End If

End If

End Sub

Public Sub UpdateDataSet()

Dim oDr As DataRow

If m_CompanyDataset.Tables(0).Rows.Count 0 Then

oDr = m_CompanyDataset.Tables(0).Rows.Find(ID)

oDr("OfficeID") = IIf(OfficeID <Nothing, OfficeID, DBNull.Value)

oDr("CompanyID") = IIf(CompanyID <Nothing, CompanyID, DBNull.Value)

oDr("AliasID") = IIf(AliasID <Nothing, AliasID, DBNull.Value)

oDr("CompanyName") = IIf(CompanyName <Nothing, CompanyName, DBNull.Value)

End If

End Sub

Public Function GetOutput() As String

Dim sb As New StringBuilder

For Each prop As PropertyInfo In Me.GetType.GetProperties

sb.Append(prop.Name & " - " & prop.GetValue(Me, Nothing) & "<br>")

Next

Return sb.ToString

End Function

Public Sub SaveChanges()

UpdateDataSet()

m_oData.SaveDataSet(m_CompanyDataset)

End Sub

#End Region

End Class

Jun 12 '07 #1
7 1539
Create a CompanyBaseSerializer class that *is* serializable that can convert
from CompanyBase to itself and back, and then just add some water:

public shared sub SaveSessionCompany(obj as CompanyBase)
Dim CBaseSerialized as CompanyBaseSerializer
CBaseSerialized=CompanyBaseSerializer.GetSerializa ble(obj)
Session("companyobject")=CBaseSerialized
end function

public shared function GetSessionCompany() as CompanyBase
Dim CBaseSerialized as CompanyBaseSerializer=Session("companyobject")
return CompanyBaseSerializer.GetCompanyObject(CBaseSerial ized)
end function

"RSH" <wa*************@yahoo.comha scritto nel messaggio
news:ON****************@TK2MSFTNGP05.phx.gbl...
>I am struggling with a concept I'm not really finding a lot of in depth
articles on but Im sure others have had similar issues.

What is the best practice when it comes to persisting custom created
objects
during a user's session?

I have created several objects that when run with an Out of Process
session
state they cause the dreaded "Unable to serialize the session state.
Please
note that non-serializable objects or MarshalByRef objects are not
permitted
when session state mode is 'StateServer' or 'SQLServer'. " exception.

In the past I have created a base object that contained all of the
serializable properties, then create a concrete class underneath and
basically stripped the base class off and saved it in a session variable
and
then "bolted" it back up when needed on other pages (.net 1.1). But now
that I am at the point where I need to develop an application I am
wondering
how to deal with custom objects and persisting them properly.

Im struggling using OOP techniques for the web. How are other people
handling these techniques?

This is an example of the class that wont serialize, but I need to
reference
it throughout the user's session:

Thanks,
Ron
<Serializable()Public Class CompanyBase

#Region "Member Variables"

Private m_ID As System.Int32

Private m_OfficeID As System.String

Private m_CompanyID As System.String

Private m_AliasID As System.String

Private m_CompanyName As System.String

Private m_DataSource As DataSourceType

Private m_oData As BaseDataClass

#End Region

#Region "Member Properties"

Public Property ID() As System.Int32

Get

Return m_ID

End Get

Set(ByVal Value As System.Int32)

m_ID = Value

End Set

End Property

Public Property OfficeID() As System.String

Get

Return m_OfficeID

End Get

Set(ByVal Value As System.String)

m_OfficeID = Value

m_CompanyDataset.Tables(0).Rows(0).Item("OfficeID" ) = Value

End Set

End Property

Public Property CompanyID() As System.String

Get

Return m_CompanyID

End Get

Set(ByVal Value As System.String)

m_CompanyID = Value

End Set

End Property

Public Property AliasID() As System.String

Get

Return m_AliasID

End Get

Set(ByVal Value As System.String)

m_AliasID = Value

End Set

End Property

Public Property CompanyName() As System.String

Get

Return m_CompanyName

End Get

Set(ByVal Value As System.String)

m_CompanyName = Value

End Set

End Property

#End Region

#Region "Constructor"

Public Sub New()

End Sub

Public Sub New(ByVal companyID As String)

m_CompanyID = companyID

m_DataSource = DataSourceType.SQLServer

DataSourceBuilder()

End Sub

#End Region

#Region "Member Methods"

Private Sub DataSourceBuilder()

If m_DataSource = DataSourceType.XML Then

m_File = HttpContext.Current.Request.PhysicalApplicationPat h &
Me.CompanyID
& "_Company.xml"

m_oData = DataFactory.GetDataClass(m_File, DataSourceType.XML)

m_oData.ConnectionString = m_File

m_oData.PrimaryKey = "ID"

ElseIf m_DataSource = DataSourceType.Access Then

m_File = HttpContext.Current.Request.PhysicalApplicationPat h &
"Global.mdb"

m_oData = DataFactory.GetDataClass(m_File, DataSourceType.Access)

m_oData.ConnectionString = m_File

m_oData.PrimaryKey = "ID"

m_oData.SQLString = "select * from companies WHERE CompanyID = '" &
m_CompanyID & "'"

ElseIf m_DataSource = DataSourceType.SQLServer Then

m_oData = DataFactory.GetDataClass("Global", DataSourceType.SQLServer)

m_oData.SQLString = "select * from Global.dbo.companies WITH(NOLOCK) WHERE
CompanyID = '" & m_CompanyID & "'"

m_oData.PrimaryKey = "ID"

End If

m_CompanyDataset = m_oData.GetDataSet()

BindProperties()

End Sub

Private Sub BindProperties()

Dim oDr As DataRow

If Not CompanyID Is Nothing Then

If m_CompanyDataset.Tables(0).Rows.Count 0 Then

oDr = m_CompanyDataset.Tables(0).Rows(0)

ID = IIf(Not IsDBNull(oDr("ID")), oDr("ID"), Nothing)

OfficeID = IIf(Not IsDBNull(oDr("OfficeID")), oDr("OfficeID"), Nothing)

CompanyID = IIf(Not IsDBNull(oDr("CompanyID")), oDr("CompanyID"), Nothing)

AliasID = IIf(Not IsDBNull(oDr("AliasID")), oDr("AliasID"), Nothing)

CompanyName = IIf(Not IsDBNull(oDr("CompanyName")), oDr("CompanyName"),
Nothing)

End If

End If

End Sub

Public Sub UpdateDataSet()

Dim oDr As DataRow

If m_CompanyDataset.Tables(0).Rows.Count 0 Then

oDr = m_CompanyDataset.Tables(0).Rows.Find(ID)

oDr("OfficeID") = IIf(OfficeID <Nothing, OfficeID, DBNull.Value)

oDr("CompanyID") = IIf(CompanyID <Nothing, CompanyID, DBNull.Value)

oDr("AliasID") = IIf(AliasID <Nothing, AliasID, DBNull.Value)

oDr("CompanyName") = IIf(CompanyName <Nothing, CompanyName,
DBNull.Value)

End If

End Sub

Public Function GetOutput() As String

Dim sb As New StringBuilder

For Each prop As PropertyInfo In Me.GetType.GetProperties

sb.Append(prop.Name & " - " & prop.GetValue(Me, Nothing) & "<br>")

Next

Return sb.ToString

End Function

Public Sub SaveChanges()

UpdateDataSet()

m_oData.SaveDataSet(m_CompanyDataset)

End Sub

#End Region

End Class
Jun 12 '07 #2
RSH
Laura,

Thanks for your assistance!

I am only confused about the
"CBaseSerialized=CompanyBaseSerializer.GetSerializ able(obj)" part. What
does that function look like?

Thanks!
Ron


"Laura T." <LT*****@yahoo.comwrote in message
news:uX**************@TK2MSFTNGP02.phx.gbl...
Create a CompanyBaseSerializer class that *is* serializable that can
convert from CompanyBase to itself and back, and then just add some water:

public shared sub SaveSessionCompany(obj as CompanyBase)
Dim CBaseSerialized as CompanyBaseSerializer
CBaseSerialized=CompanyBaseSerializer.GetSerializa ble(obj)
Session("companyobject")=CBaseSerialized
end function

public shared function GetSessionCompany() as CompanyBase
Dim CBaseSerialized as CompanyBaseSerializer=Session("companyobject")
return CompanyBaseSerializer.GetCompanyObject(CBaseSerial ized)
end function

"RSH" <wa*************@yahoo.comha scritto nel messaggio
news:ON****************@TK2MSFTNGP05.phx.gbl...
>>I am struggling with a concept I'm not really finding a lot of in depth
articles on but Im sure others have had similar issues.

What is the best practice when it comes to persisting custom created
objects
during a user's session?

I have created several objects that when run with an Out of Process
session
state they cause the dreaded "Unable to serialize the session state.
Please
note that non-serializable objects or MarshalByRef objects are not
permitted
when session state mode is 'StateServer' or 'SQLServer'. " exception.

In the past I have created a base object that contained all of the
serializable properties, then create a concrete class underneath and
basically stripped the base class off and saved it in a session variable
and
then "bolted" it back up when needed on other pages (.net 1.1). But now
that I am at the point where I need to develop an application I am
wondering
how to deal with custom objects and persisting them properly.

Im struggling using OOP techniques for the web. How are other people
handling these techniques?

This is an example of the class that wont serialize, but I need to
reference
it throughout the user's session:

Thanks,
Ron
<Serializable()Public Class CompanyBase

#Region "Member Variables"

Private m_ID As System.Int32

Private m_OfficeID As System.String

Private m_CompanyID As System.String

Private m_AliasID As System.String

Private m_CompanyName As System.String

Private m_DataSource As DataSourceType

Private m_oData As BaseDataClass

#End Region

#Region "Member Properties"

Public Property ID() As System.Int32

Get

Return m_ID

End Get

Set(ByVal Value As System.Int32)

m_ID = Value

End Set

End Property

Public Property OfficeID() As System.String

Get

Return m_OfficeID

End Get

Set(ByVal Value As System.String)

m_OfficeID = Value

m_CompanyDataset.Tables(0).Rows(0).Item("OfficeID ") = Value

End Set

End Property

Public Property CompanyID() As System.String

Get

Return m_CompanyID

End Get

Set(ByVal Value As System.String)

m_CompanyID = Value

End Set

End Property

Public Property AliasID() As System.String

Get

Return m_AliasID

End Get

Set(ByVal Value As System.String)

m_AliasID = Value

End Set

End Property

Public Property CompanyName() As System.String

Get

Return m_CompanyName

End Get

Set(ByVal Value As System.String)

m_CompanyName = Value

End Set

End Property

#End Region

#Region "Constructor"

Public Sub New()

End Sub

Public Sub New(ByVal companyID As String)

m_CompanyID = companyID

m_DataSource = DataSourceType.SQLServer

DataSourceBuilder()

End Sub

#End Region

#Region "Member Methods"

Private Sub DataSourceBuilder()

If m_DataSource = DataSourceType.XML Then

m_File = HttpContext.Current.Request.PhysicalApplicationPat h &
Me.CompanyID
& "_Company.xml"

m_oData = DataFactory.GetDataClass(m_File, DataSourceType.XML)

m_oData.ConnectionString = m_File

m_oData.PrimaryKey = "ID"

ElseIf m_DataSource = DataSourceType.Access Then

m_File = HttpContext.Current.Request.PhysicalApplicationPat h &
"Global.mdb"

m_oData = DataFactory.GetDataClass(m_File, DataSourceType.Access)

m_oData.ConnectionString = m_File

m_oData.PrimaryKey = "ID"

m_oData.SQLString = "select * from companies WHERE CompanyID = '" &
m_CompanyID & "'"

ElseIf m_DataSource = DataSourceType.SQLServer Then

m_oData = DataFactory.GetDataClass("Global", DataSourceType.SQLServer)

m_oData.SQLString = "select * from Global.dbo.companies WITH(NOLOCK)
WHERE
CompanyID = '" & m_CompanyID & "'"

m_oData.PrimaryKey = "ID"

End If

m_CompanyDataset = m_oData.GetDataSet()

BindProperties()

End Sub

Private Sub BindProperties()

Dim oDr As DataRow

If Not CompanyID Is Nothing Then

If m_CompanyDataset.Tables(0).Rows.Count 0 Then

oDr = m_CompanyDataset.Tables(0).Rows(0)

ID = IIf(Not IsDBNull(oDr("ID")), oDr("ID"), Nothing)

OfficeID = IIf(Not IsDBNull(oDr("OfficeID")), oDr("OfficeID"), Nothing)

CompanyID = IIf(Not IsDBNull(oDr("CompanyID")), oDr("CompanyID"),
Nothing)

AliasID = IIf(Not IsDBNull(oDr("AliasID")), oDr("AliasID"), Nothing)

CompanyName = IIf(Not IsDBNull(oDr("CompanyName")), oDr("CompanyName"),
Nothing)

End If

End If

End Sub

Public Sub UpdateDataSet()

Dim oDr As DataRow

If m_CompanyDataset.Tables(0).Rows.Count 0 Then

oDr = m_CompanyDataset.Tables(0).Rows.Find(ID)

oDr("OfficeID") = IIf(OfficeID <Nothing, OfficeID, DBNull.Value)

oDr("CompanyID") = IIf(CompanyID <Nothing, CompanyID, DBNull.Value)

oDr("AliasID") = IIf(AliasID <Nothing, AliasID, DBNull.Value)

oDr("CompanyName") = IIf(CompanyName <Nothing, CompanyName,
DBNull.Value)

End If

End Sub

Public Function GetOutput() As String

Dim sb As New StringBuilder

For Each prop As PropertyInfo In Me.GetType.GetProperties

sb.Append(prop.Name & " - " & prop.GetValue(Me, Nothing) & "<br>")

Next

Return sb.ToString

End Function

Public Sub SaveChanges()

UpdateDataSet()

m_oData.SaveDataSet(m_CompanyDataset)

End Sub

#End Region

End Class

Jun 12 '07 #3
Ron,

ASPNET pages are not persistent, therefore you have to construct them every
time new.

You want more OOP. OOP is not Object Oriented as some think. It is Object
Oriented Programming. (Make your program exist from objects). A OO dataclass
does your program not make OOP, for that the completely OOP dataset or only
the datatable is mostly much more sufficient.

Cor

"RSH" <wa*************@yahoo.comschreef in bericht
news:ON****************@TK2MSFTNGP05.phx.gbl...
>I am struggling with a concept I'm not really finding a lot of in depth
articles on but Im sure others have had similar issues.

What is the best practice when it comes to persisting custom created
objects
during a user's session?

I have created several objects that when run with an Out of Process
session
state they cause the dreaded "Unable to serialize the session state.
Please
note that non-serializable objects or MarshalByRef objects are not
permitted
when session state mode is 'StateServer' or 'SQLServer'. " exception.

In the past I have created a base object that contained all of the
serializable properties, then create a concrete class underneath and
basically stripped the base class off and saved it in a session variable
and
then "bolted" it back up when needed on other pages (.net 1.1). But now
that I am at the point where I need to develop an application I am
wondering
how to deal with custom objects and persisting them properly.

Im struggling using OOP techniques for the web. How are other people
handling these techniques?

This is an example of the class that wont serialize, but I need to
reference
it throughout the user's session:

Thanks,
Ron
<Serializable()Public Class CompanyBase

#Region "Member Variables"

Private m_ID As System.Int32

Private m_OfficeID As System.String

Private m_CompanyID As System.String

Private m_AliasID As System.String

Private m_CompanyName As System.String

Private m_DataSource As DataSourceType

Private m_oData As BaseDataClass

#End Region

#Region "Member Properties"

Public Property ID() As System.Int32

Get

Return m_ID

End Get

Set(ByVal Value As System.Int32)

m_ID = Value

End Set

End Property

Public Property OfficeID() As System.String

Get

Return m_OfficeID

End Get

Set(ByVal Value As System.String)

m_OfficeID = Value

m_CompanyDataset.Tables(0).Rows(0).Item("OfficeID" ) = Value

End Set

End Property

Public Property CompanyID() As System.String

Get

Return m_CompanyID

End Get

Set(ByVal Value As System.String)

m_CompanyID = Value

End Set

End Property

Public Property AliasID() As System.String

Get

Return m_AliasID

End Get

Set(ByVal Value As System.String)

m_AliasID = Value

End Set

End Property

Public Property CompanyName() As System.String

Get

Return m_CompanyName

End Get

Set(ByVal Value As System.String)

m_CompanyName = Value

End Set

End Property

#End Region

#Region "Constructor"

Public Sub New()

End Sub

Public Sub New(ByVal companyID As String)

m_CompanyID = companyID

m_DataSource = DataSourceType.SQLServer

DataSourceBuilder()

End Sub

#End Region

#Region "Member Methods"

Private Sub DataSourceBuilder()

If m_DataSource = DataSourceType.XML Then

m_File = HttpContext.Current.Request.PhysicalApplicationPat h &
Me.CompanyID
& "_Company.xml"

m_oData = DataFactory.GetDataClass(m_File, DataSourceType.XML)

m_oData.ConnectionString = m_File

m_oData.PrimaryKey = "ID"

ElseIf m_DataSource = DataSourceType.Access Then

m_File = HttpContext.Current.Request.PhysicalApplicationPat h &
"Global.mdb"

m_oData = DataFactory.GetDataClass(m_File, DataSourceType.Access)

m_oData.ConnectionString = m_File

m_oData.PrimaryKey = "ID"

m_oData.SQLString = "select * from companies WHERE CompanyID = '" &
m_CompanyID & "'"

ElseIf m_DataSource = DataSourceType.SQLServer Then

m_oData = DataFactory.GetDataClass("Global", DataSourceType.SQLServer)

m_oData.SQLString = "select * from Global.dbo.companies WITH(NOLOCK) WHERE
CompanyID = '" & m_CompanyID & "'"

m_oData.PrimaryKey = "ID"

End If

m_CompanyDataset = m_oData.GetDataSet()

BindProperties()

End Sub

Private Sub BindProperties()

Dim oDr As DataRow

If Not CompanyID Is Nothing Then

If m_CompanyDataset.Tables(0).Rows.Count 0 Then

oDr = m_CompanyDataset.Tables(0).Rows(0)

ID = IIf(Not IsDBNull(oDr("ID")), oDr("ID"), Nothing)

OfficeID = IIf(Not IsDBNull(oDr("OfficeID")), oDr("OfficeID"), Nothing)

CompanyID = IIf(Not IsDBNull(oDr("CompanyID")), oDr("CompanyID"), Nothing)

AliasID = IIf(Not IsDBNull(oDr("AliasID")), oDr("AliasID"), Nothing)

CompanyName = IIf(Not IsDBNull(oDr("CompanyName")), oDr("CompanyName"),
Nothing)

End If

End If

End Sub

Public Sub UpdateDataSet()

Dim oDr As DataRow

If m_CompanyDataset.Tables(0).Rows.Count 0 Then

oDr = m_CompanyDataset.Tables(0).Rows.Find(ID)

oDr("OfficeID") = IIf(OfficeID <Nothing, OfficeID, DBNull.Value)

oDr("CompanyID") = IIf(CompanyID <Nothing, CompanyID, DBNull.Value)

oDr("AliasID") = IIf(AliasID <Nothing, AliasID, DBNull.Value)

oDr("CompanyName") = IIf(CompanyName <Nothing, CompanyName,
DBNull.Value)

End If

End Sub

Public Function GetOutput() As String

Dim sb As New StringBuilder

For Each prop As PropertyInfo In Me.GetType.GetProperties

sb.Append(prop.Name & " - " & prop.GetValue(Me, Nothing) & "<br>")

Next

Return sb.ToString

End Function

Public Sub SaveChanges()

UpdateDataSet()

m_oData.SaveDataSet(m_CompanyDataset)

End Sub

#End Region

End Class

Jun 12 '07 #4
RSH
Cor,

Thanks for the input.

I agree totally. I am using a data class because the back side of the
application can read/write XML, SQLServer or Access database tables based on
the user. I didn't design the back end systems in place, so I have
implemented an abstract data class with conrete clases underneith that
support the read/writes to and from the data stores. I am using the company
Information Object to abstract that information away from the user
interface, and while it isn't apparent in the example there are quite a few
additional properties that reside in different tables, but since they are
directly part of a company it makes sense in scope. In addition i need the
user to be able to preview changes before they commit them to the datastore
which is why I need to persist the object across multiple pages.

Ron
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:O$**************@TK2MSFTNGP03.phx.gbl...
Ron,

ASPNET pages are not persistent, therefore you have to construct them
every time new.

You want more OOP. OOP is not Object Oriented as some think. It is Object
Oriented Programming. (Make your program exist from objects). A OO
dataclass does your program not make OOP, for that the completely OOP
dataset or only the datatable is mostly much more sufficient.

Cor

"RSH" <wa*************@yahoo.comschreef in bericht
news:ON****************@TK2MSFTNGP05.phx.gbl...
>>I am struggling with a concept I'm not really finding a lot of in depth
articles on but Im sure others have had similar issues.

What is the best practice when it comes to persisting custom created
objects
during a user's session?

I have created several objects that when run with an Out of Process
session
state they cause the dreaded "Unable to serialize the session state.
Please
note that non-serializable objects or MarshalByRef objects are not
permitted
when session state mode is 'StateServer' or 'SQLServer'. " exception.

In the past I have created a base object that contained all of the
serializable properties, then create a concrete class underneath and
basically stripped the base class off and saved it in a session variable
and
then "bolted" it back up when needed on other pages (.net 1.1). But now
that I am at the point where I need to develop an application I am
wondering
how to deal with custom objects and persisting them properly.

Im struggling using OOP techniques for the web. How are other people
handling these techniques?

This is an example of the class that wont serialize, but I need to
reference
it throughout the user's session:

Thanks,
Ron
<Serializable()Public Class CompanyBase

#Region "Member Variables"

Private m_ID As System.Int32

Private m_OfficeID As System.String

Private m_CompanyID As System.String

Private m_AliasID As System.String

Private m_CompanyName As System.String

Private m_DataSource As DataSourceType

Private m_oData As BaseDataClass

#End Region

#Region "Member Properties"

Public Property ID() As System.Int32

Get

Return m_ID

End Get

Set(ByVal Value As System.Int32)

m_ID = Value

End Set

End Property

Public Property OfficeID() As System.String

Get

Return m_OfficeID

End Get

Set(ByVal Value As System.String)

m_OfficeID = Value

m_CompanyDataset.Tables(0).Rows(0).Item("OfficeID ") = Value

End Set

End Property

Public Property CompanyID() As System.String

Get

Return m_CompanyID

End Get

Set(ByVal Value As System.String)

m_CompanyID = Value

End Set

End Property

Public Property AliasID() As System.String

Get

Return m_AliasID

End Get

Set(ByVal Value As System.String)

m_AliasID = Value

End Set

End Property

Public Property CompanyName() As System.String

Get

Return m_CompanyName

End Get

Set(ByVal Value As System.String)

m_CompanyName = Value

End Set

End Property

#End Region

#Region "Constructor"

Public Sub New()

End Sub

Public Sub New(ByVal companyID As String)

m_CompanyID = companyID

m_DataSource = DataSourceType.SQLServer

DataSourceBuilder()

End Sub

#End Region

#Region "Member Methods"

Private Sub DataSourceBuilder()

If m_DataSource = DataSourceType.XML Then

m_File = HttpContext.Current.Request.PhysicalApplicationPat h &
Me.CompanyID
& "_Company.xml"

m_oData = DataFactory.GetDataClass(m_File, DataSourceType.XML)

m_oData.ConnectionString = m_File

m_oData.PrimaryKey = "ID"

ElseIf m_DataSource = DataSourceType.Access Then

m_File = HttpContext.Current.Request.PhysicalApplicationPat h &
"Global.mdb"

m_oData = DataFactory.GetDataClass(m_File, DataSourceType.Access)

m_oData.ConnectionString = m_File

m_oData.PrimaryKey = "ID"

m_oData.SQLString = "select * from companies WHERE CompanyID = '" &
m_CompanyID & "'"

ElseIf m_DataSource = DataSourceType.SQLServer Then

m_oData = DataFactory.GetDataClass("Global", DataSourceType.SQLServer)

m_oData.SQLString = "select * from Global.dbo.companies WITH(NOLOCK)
WHERE
CompanyID = '" & m_CompanyID & "'"

m_oData.PrimaryKey = "ID"

End If

m_CompanyDataset = m_oData.GetDataSet()

BindProperties()

End Sub

Private Sub BindProperties()

Dim oDr As DataRow

If Not CompanyID Is Nothing Then

If m_CompanyDataset.Tables(0).Rows.Count 0 Then

oDr = m_CompanyDataset.Tables(0).Rows(0)

ID = IIf(Not IsDBNull(oDr("ID")), oDr("ID"), Nothing)

OfficeID = IIf(Not IsDBNull(oDr("OfficeID")), oDr("OfficeID"), Nothing)

CompanyID = IIf(Not IsDBNull(oDr("CompanyID")), oDr("CompanyID"),
Nothing)

AliasID = IIf(Not IsDBNull(oDr("AliasID")), oDr("AliasID"), Nothing)

CompanyName = IIf(Not IsDBNull(oDr("CompanyName")), oDr("CompanyName"),
Nothing)

End If

End If

End Sub

Public Sub UpdateDataSet()

Dim oDr As DataRow

If m_CompanyDataset.Tables(0).Rows.Count 0 Then

oDr = m_CompanyDataset.Tables(0).Rows.Find(ID)

oDr("OfficeID") = IIf(OfficeID <Nothing, OfficeID, DBNull.Value)

oDr("CompanyID") = IIf(CompanyID <Nothing, CompanyID, DBNull.Value)

oDr("AliasID") = IIf(AliasID <Nothing, AliasID, DBNull.Value)

oDr("CompanyName") = IIf(CompanyName <Nothing, CompanyName,
DBNull.Value)

End If

End Sub

Public Function GetOutput() As String

Dim sb As New StringBuilder

For Each prop As PropertyInfo In Me.GetType.GetProperties

sb.Append(prop.Name & " - " & prop.GetValue(Me, Nothing) & "<br>")

Next

Return sb.ToString

End Function

Public Sub SaveChanges()

UpdateDataSet()

m_oData.SaveDataSet(m_CompanyDataset)

End Sub

#End Region

End Class


Jun 12 '07 #5
Ron,

Be aware that Static in ASP.Net means accessed by all users.
I hope this warns you enough.

Cor

"RSH" <wa*************@yahoo.comschreef in bericht
news:OC**************@TK2MSFTNGP03.phx.gbl...
Cor,

Thanks for the input.

I agree totally. I am using a data class because the back side of the
application can read/write XML, SQLServer or Access database tables based
on the user. I didn't design the back end systems in place, so I have
implemented an abstract data class with conrete clases underneith that
support the read/writes to and from the data stores. I am using the
company Information Object to abstract that information away from the user
interface, and while it isn't apparent in the example there are quite a
few additional properties that reside in different tables, but since they
are directly part of a company it makes sense in scope. In addition i
need the user to be able to preview changes before they commit them to the
datastore which is why I need to persist the object across multiple pages.

Ron
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:O$**************@TK2MSFTNGP03.phx.gbl...
>Ron,

ASPNET pages are not persistent, therefore you have to construct them
every time new.

You want more OOP. OOP is not Object Oriented as some think. It is Object
Oriented Programming. (Make your program exist from objects). A OO
dataclass does your program not make OOP, for that the completely OOP
dataset or only the datatable is mostly much more sufficient.

Cor

"RSH" <wa*************@yahoo.comschreef in bericht
news:ON****************@TK2MSFTNGP05.phx.gbl...
>>>I am struggling with a concept I'm not really finding a lot of in depth
articles on but Im sure others have had similar issues.

What is the best practice when it comes to persisting custom created
objects
during a user's session?

I have created several objects that when run with an Out of Process
session
state they cause the dreaded "Unable to serialize the session state.
Please
note that non-serializable objects or MarshalByRef objects are not
permitted
when session state mode is 'StateServer' or 'SQLServer'. " exception.

In the past I have created a base object that contained all of the
serializable properties, then create a concrete class underneath and
basically stripped the base class off and saved it in a session variable
and
then "bolted" it back up when needed on other pages (.net 1.1). But now
that I am at the point where I need to develop an application I am
wondering
how to deal with custom objects and persisting them properly.

Im struggling using OOP techniques for the web. How are other people
handling these techniques?

This is an example of the class that wont serialize, but I need to
reference
it throughout the user's session:

Thanks,
Ron
<Serializable()Public Class CompanyBase

#Region "Member Variables"

Private m_ID As System.Int32

Private m_OfficeID As System.String

Private m_CompanyID As System.String

Private m_AliasID As System.String

Private m_CompanyName As System.String

Private m_DataSource As DataSourceType

Private m_oData As BaseDataClass

#End Region

#Region "Member Properties"

Public Property ID() As System.Int32

Get

Return m_ID

End Get

Set(ByVal Value As System.Int32)

m_ID = Value

End Set

End Property

Public Property OfficeID() As System.String

Get

Return m_OfficeID

End Get

Set(ByVal Value As System.String)

m_OfficeID = Value

m_CompanyDataset.Tables(0).Rows(0).Item("OfficeI D") = Value

End Set

End Property

Public Property CompanyID() As System.String

Get

Return m_CompanyID

End Get

Set(ByVal Value As System.String)

m_CompanyID = Value

End Set

End Property

Public Property AliasID() As System.String

Get

Return m_AliasID

End Get

Set(ByVal Value As System.String)

m_AliasID = Value

End Set

End Property

Public Property CompanyName() As System.String

Get

Return m_CompanyName

End Get

Set(ByVal Value As System.String)

m_CompanyName = Value

End Set

End Property

#End Region

#Region "Constructor"

Public Sub New()

End Sub

Public Sub New(ByVal companyID As String)

m_CompanyID = companyID

m_DataSource = DataSourceType.SQLServer

DataSourceBuilder()

End Sub

#End Region

#Region "Member Methods"

Private Sub DataSourceBuilder()

If m_DataSource = DataSourceType.XML Then

m_File = HttpContext.Current.Request.PhysicalApplicationPat h &
Me.CompanyID
& "_Company.xml"

m_oData = DataFactory.GetDataClass(m_File, DataSourceType.XML)

m_oData.ConnectionString = m_File

m_oData.PrimaryKey = "ID"

ElseIf m_DataSource = DataSourceType.Access Then

m_File = HttpContext.Current.Request.PhysicalApplicationPat h &
"Global.mdb"

m_oData = DataFactory.GetDataClass(m_File, DataSourceType.Access)

m_oData.ConnectionString = m_File

m_oData.PrimaryKey = "ID"

m_oData.SQLString = "select * from companies WHERE CompanyID = '" &
m_CompanyID & "'"

ElseIf m_DataSource = DataSourceType.SQLServer Then

m_oData = DataFactory.GetDataClass("Global", DataSourceType.SQLServer)

m_oData.SQLString = "select * from Global.dbo.companies WITH(NOLOCK)
WHERE
CompanyID = '" & m_CompanyID & "'"

m_oData.PrimaryKey = "ID"

End If

m_CompanyDataset = m_oData.GetDataSet()

BindProperties()

End Sub

Private Sub BindProperties()

Dim oDr As DataRow

If Not CompanyID Is Nothing Then

If m_CompanyDataset.Tables(0).Rows.Count 0 Then

oDr = m_CompanyDataset.Tables(0).Rows(0)

ID = IIf(Not IsDBNull(oDr("ID")), oDr("ID"), Nothing)

OfficeID = IIf(Not IsDBNull(oDr("OfficeID")), oDr("OfficeID"), Nothing)

CompanyID = IIf(Not IsDBNull(oDr("CompanyID")), oDr("CompanyID"),
Nothing)

AliasID = IIf(Not IsDBNull(oDr("AliasID")), oDr("AliasID"), Nothing)

CompanyName = IIf(Not IsDBNull(oDr("CompanyName")), oDr("CompanyName"),
Nothing)

End If

End If

End Sub

Public Sub UpdateDataSet()

Dim oDr As DataRow

If m_CompanyDataset.Tables(0).Rows.Count 0 Then

oDr = m_CompanyDataset.Tables(0).Rows.Find(ID)

oDr("OfficeID") = IIf(OfficeID <Nothing, OfficeID, DBNull.Value)

oDr("CompanyID") = IIf(CompanyID <Nothing, CompanyID, DBNull.Value)

oDr("AliasID") = IIf(AliasID <Nothing, AliasID, DBNull.Value)

oDr("CompanyName") = IIf(CompanyName <Nothing, CompanyName,
DBNull.Value)

End If

End Sub

Public Function GetOutput() As String

Dim sb As New StringBuilder

For Each prop As PropertyInfo In Me.GetType.GetProperties

sb.Append(prop.Name & " - " & prop.GetValue(Me, Nothing) & "<br>")

Next

Return sb.ToString

End Function

Public Sub SaveChanges()

UpdateDataSet()

m_oData.SaveDataSet(m_CompanyDataset)

End Sub

#End Region

End Class



Jun 13 '07 #6
RSH
Cor,

Is there a Static type modifier that is session specific.

Ron

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:eA**************@TK2MSFTNGP02.phx.gbl...
Ron,

Be aware that Static in ASP.Net means accessed by all users.
I hope this warns you enough.

Cor

"RSH" <wa*************@yahoo.comschreef in bericht
news:OC**************@TK2MSFTNGP03.phx.gbl...
>Cor,

Thanks for the input.

I agree totally. I am using a data class because the back side of the
application can read/write XML, SQLServer or Access database tables based
on the user. I didn't design the back end systems in place, so I have
implemented an abstract data class with conrete clases underneith that
support the read/writes to and from the data stores. I am using the
company Information Object to abstract that information away from the
user interface, and while it isn't apparent in the example there are
quite a few additional properties that reside in different tables, but
since they are directly part of a company it makes sense in scope. In
addition i need the user to be able to preview changes before they commit
them to the datastore which is why I need to persist the object across
multiple pages.

Ron
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:O$**************@TK2MSFTNGP03.phx.gbl...
>>Ron,

ASPNET pages are not persistent, therefore you have to construct them
every time new.

You want more OOP. OOP is not Object Oriented as some think. It is
Object Oriented Programming. (Make your program exist from objects). A
OO dataclass does your program not make OOP, for that the completely OOP
dataset or only the datatable is mostly much more sufficient.

Cor

"RSH" <wa*************@yahoo.comschreef in bericht
news:ON****************@TK2MSFTNGP05.phx.gbl.. .
I am struggling with a concept I'm not really finding a lot of in depth
articles on but Im sure others have had similar issues.

What is the best practice when it comes to persisting custom created
objects
during a user's session?

I have created several objects that when run with an Out of Process
session
state they cause the dreaded "Unable to serialize the session state.
Please
note that non-serializable objects or MarshalByRef objects are not
permitted
when session state mode is 'StateServer' or 'SQLServer'. " exception.

In the past I have created a base object that contained all of the
serializable properties, then create a concrete class underneath and
basically stripped the base class off and saved it in a session
variable and
then "bolted" it back up when needed on other pages (.net 1.1). But
now
that I am at the point where I need to develop an application I am
wondering
how to deal with custom objects and persisting them properly.

Im struggling using OOP techniques for the web. How are other people
handling these techniques?

This is an example of the class that wont serialize, but I need to
reference
it throughout the user's session:

Thanks,
Ron
<Serializable()Public Class CompanyBase

#Region "Member Variables"

Private m_ID As System.Int32

Private m_OfficeID As System.String

Private m_CompanyID As System.String

Private m_AliasID As System.String

Private m_CompanyName As System.String

Private m_DataSource As DataSourceType

Private m_oData As BaseDataClass

#End Region

#Region "Member Properties"

Public Property ID() As System.Int32

Get

Return m_ID

End Get

Set(ByVal Value As System.Int32)

m_ID = Value

End Set

End Property

Public Property OfficeID() As System.String

Get

Return m_OfficeID

End Get

Set(ByVal Value As System.String)

m_OfficeID = Value

m_CompanyDataset.Tables(0).Rows(0).Item("Office ID") = Value

End Set

End Property

Public Property CompanyID() As System.String

Get

Return m_CompanyID

End Get

Set(ByVal Value As System.String)

m_CompanyID = Value

End Set

End Property

Public Property AliasID() As System.String

Get

Return m_AliasID

End Get

Set(ByVal Value As System.String)

m_AliasID = Value

End Set

End Property

Public Property CompanyName() As System.String

Get

Return m_CompanyName

End Get

Set(ByVal Value As System.String)

m_CompanyName = Value

End Set

End Property

#End Region

#Region "Constructor"

Public Sub New()

End Sub

Public Sub New(ByVal companyID As String)

m_CompanyID = companyID

m_DataSource = DataSourceType.SQLServer

DataSourceBuilder()

End Sub

#End Region

#Region "Member Methods"

Private Sub DataSourceBuilder()

If m_DataSource = DataSourceType.XML Then

m_File = HttpContext.Current.Request.PhysicalApplicationPat h &
Me.CompanyID
& "_Company.xml"

m_oData = DataFactory.GetDataClass(m_File, DataSourceType.XML)

m_oData.ConnectionString = m_File

m_oData.PrimaryKey = "ID"

ElseIf m_DataSource = DataSourceType.Access Then

m_File = HttpContext.Current.Request.PhysicalApplicationPat h &
"Global.mdb"

m_oData = DataFactory.GetDataClass(m_File, DataSourceType.Access)

m_oData.ConnectionString = m_File

m_oData.PrimaryKey = "ID"

m_oData.SQLString = "select * from companies WHERE CompanyID = '" &
m_CompanyID & "'"

ElseIf m_DataSource = DataSourceType.SQLServer Then

m_oData = DataFactory.GetDataClass("Global", DataSourceType.SQLServer)

m_oData.SQLString = "select * from Global.dbo.companies WITH(NOLOCK)
WHERE
CompanyID = '" & m_CompanyID & "'"

m_oData.PrimaryKey = "ID"

End If

m_CompanyDataset = m_oData.GetDataSet()

BindProperties()

End Sub

Private Sub BindProperties()

Dim oDr As DataRow

If Not CompanyID Is Nothing Then

If m_CompanyDataset.Tables(0).Rows.Count 0 Then

oDr = m_CompanyDataset.Tables(0).Rows(0)

ID = IIf(Not IsDBNull(oDr("ID")), oDr("ID"), Nothing)

OfficeID = IIf(Not IsDBNull(oDr("OfficeID")), oDr("OfficeID"), Nothing)

CompanyID = IIf(Not IsDBNull(oDr("CompanyID")), oDr("CompanyID"),
Nothing)

AliasID = IIf(Not IsDBNull(oDr("AliasID")), oDr("AliasID"), Nothing)

CompanyName = IIf(Not IsDBNull(oDr("CompanyName")), oDr("CompanyName"),
Nothing)

End If

End If

End Sub

Public Sub UpdateDataSet()

Dim oDr As DataRow

If m_CompanyDataset.Tables(0).Rows.Count 0 Then

oDr = m_CompanyDataset.Tables(0).Rows.Find(ID)

oDr("OfficeID") = IIf(OfficeID <Nothing, OfficeID, DBNull.Value)

oDr("CompanyID") = IIf(CompanyID <Nothing, CompanyID, DBNull.Value)

oDr("AliasID") = IIf(AliasID <Nothing, AliasID, DBNull.Value)

oDr("CompanyName") = IIf(CompanyName <Nothing, CompanyName,
DBNull.Value)

End If

End Sub

Public Function GetOutput() As String

Dim sb As New StringBuilder

For Each prop As PropertyInfo In Me.GetType.GetProperties

sb.Append(prop.Name & " - " & prop.GetValue(Me, Nothing) & "<br>")

Next

Return sb.ToString

End Function

Public Sub SaveChanges()

UpdateDataSet()

m_oData.SaveDataSet(m_CompanyDataset)

End Sub

#End Region

End Class





Jun 13 '07 #7
Cor,

I am not sure what you mean, however the good old session is to keep data
static to one session.

Cor

"RSH" <wa*************@yahoo.comschreef in bericht
news:ew**************@TK2MSFTNGP02.phx.gbl...
Cor,

Is there a Static type modifier that is session specific.

Ron

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:eA**************@TK2MSFTNGP02.phx.gbl...
>Ron,

Be aware that Static in ASP.Net means accessed by all users.
I hope this warns you enough.

Cor

"RSH" <wa*************@yahoo.comschreef in bericht
news:OC**************@TK2MSFTNGP03.phx.gbl...
>>Cor,

Thanks for the input.

I agree totally. I am using a data class because the back side of the
application can read/write XML, SQLServer or Access database tables
based on the user. I didn't design the back end systems in place, so I
have implemented an abstract data class with conrete clases underneith
that support the read/writes to and from the data stores. I am using
the company Information Object to abstract that information away from
the user interface, and while it isn't apparent in the example there are
quite a few additional properties that reside in different tables, but
since they are directly part of a company it makes sense in scope. In
addition i need the user to be able to preview changes before they
commit them to the datastore which is why I need to persist the object
across multiple pages.

Ron
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:O$**************@TK2MSFTNGP03.phx.gbl...
Ron,

ASPNET pages are not persistent, therefore you have to construct them
every time new.

You want more OOP. OOP is not Object Oriented as some think. It is
Object Oriented Programming. (Make your program exist from objects). A
OO dataclass does your program not make OOP, for that the completely
OOP dataset or only the datatable is mostly much more sufficient.

Cor

"RSH" <wa*************@yahoo.comschreef in bericht
news:ON****************@TK2MSFTNGP05.phx.gbl. ..
>I am struggling with a concept I'm not really finding a lot of in depth
articles on but Im sure others have had similar issues.
>
What is the best practice when it comes to persisting custom created
objects
during a user's session?
>
I have created several objects that when run with an Out of Process
session
state they cause the dreaded "Unable to serialize the session state.
Please
note that non-serializable objects or MarshalByRef objects are not
permitted
when session state mode is 'StateServer' or 'SQLServer'. " exception.
>
In the past I have created a base object that contained all of the
serializable properties, then create a concrete class underneath and
basically stripped the base class off and saved it in a session
variable and
then "bolted" it back up when needed on other pages (.net 1.1). But
now
that I am at the point where I need to develop an application I am
wondering
how to deal with custom objects and persisting them properly.
>
Im struggling using OOP techniques for the web. How are other people
handling these techniques?
>
This is an example of the class that wont serialize, but I need to
reference
it throughout the user's session:
>
Thanks,
Ron
>
>
<Serializable()Public Class CompanyBase
>
#Region "Member Variables"
>
Private m_ID As System.Int32
>
Private m_OfficeID As System.String
>
Private m_CompanyID As System.String
>
Private m_AliasID As System.String
>
Private m_CompanyName As System.String
>
>
>
Private m_DataSource As DataSourceType
>
Private m_oData As BaseDataClass
>
#End Region
>
#Region "Member Properties"
>
Public Property ID() As System.Int32
>
Get
>
Return m_ID
>
End Get
>
Set(ByVal Value As System.Int32)
>
m_ID = Value
>
End Set
>
End Property
>
Public Property OfficeID() As System.String
>
Get
>
Return m_OfficeID
>
End Get
>
Set(ByVal Value As System.String)
>
m_OfficeID = Value
>
m_CompanyDataset.Tables(0).Rows(0).Item("Offic eID") = Value
>
End Set
>
End Property
>
Public Property CompanyID() As System.String
>
Get
>
Return m_CompanyID
>
End Get
>
Set(ByVal Value As System.String)
>
m_CompanyID = Value
>
End Set
>
End Property
>
Public Property AliasID() As System.String
>
Get
>
Return m_AliasID
>
End Get
>
Set(ByVal Value As System.String)
>
m_AliasID = Value
>
End Set
>
End Property
>
Public Property CompanyName() As System.String
>
Get
>
Return m_CompanyName
>
End Get
>
Set(ByVal Value As System.String)
>
m_CompanyName = Value
>
End Set
>
End Property
>
>
>
#End Region
>
#Region "Constructor"
>
Public Sub New()
>
End Sub
>
Public Sub New(ByVal companyID As String)
>
m_CompanyID = companyID
>
m_DataSource = DataSourceType.SQLServer
>
DataSourceBuilder()
>
End Sub
>
#End Region
>
#Region "Member Methods"
>
Private Sub DataSourceBuilder()
>
If m_DataSource = DataSourceType.XML Then
>
m_File = HttpContext.Current.Request.PhysicalApplicationPat h &
Me.CompanyID
& "_Company.xml"
>
m_oData = DataFactory.GetDataClass(m_File, DataSourceType.XML)
>
m_oData.ConnectionString = m_File
>
m_oData.PrimaryKey = "ID"
>
ElseIf m_DataSource = DataSourceType.Access Then
>
m_File = HttpContext.Current.Request.PhysicalApplicationPat h &
"Global.mdb"
>
m_oData = DataFactory.GetDataClass(m_File, DataSourceType.Access)
>
m_oData.ConnectionString = m_File
>
m_oData.PrimaryKey = "ID"
>
m_oData.SQLString = "select * from companies WHERE CompanyID = '" &
m_CompanyID & "'"
>
ElseIf m_DataSource = DataSourceType.SQLServer Then
>
m_oData = DataFactory.GetDataClass("Global", DataSourceType.SQLServer)
>
m_oData.SQLString = "select * from Global.dbo.companies WITH(NOLOCK)
WHERE
CompanyID = '" & m_CompanyID & "'"
>
m_oData.PrimaryKey = "ID"
>
End If
>
m_CompanyDataset = m_oData.GetDataSet()
>
BindProperties()
>
End Sub
>
Private Sub BindProperties()
>
Dim oDr As DataRow
>
If Not CompanyID Is Nothing Then
>
If m_CompanyDataset.Tables(0).Rows.Count 0 Then
>
oDr = m_CompanyDataset.Tables(0).Rows(0)
>
ID = IIf(Not IsDBNull(oDr("ID")), oDr("ID"), Nothing)
>
OfficeID = IIf(Not IsDBNull(oDr("OfficeID")), oDr("OfficeID"),
Nothing)
>
CompanyID = IIf(Not IsDBNull(oDr("CompanyID")), oDr("CompanyID"),
Nothing)
>
AliasID = IIf(Not IsDBNull(oDr("AliasID")), oDr("AliasID"), Nothing)
>
CompanyName = IIf(Not IsDBNull(oDr("CompanyName")),
oDr("CompanyName"),
Nothing)
>
>
>
End If
>
End If
>
End Sub
>
Public Sub UpdateDataSet()
>
Dim oDr As DataRow
>
If m_CompanyDataset.Tables(0).Rows.Count 0 Then
>
oDr = m_CompanyDataset.Tables(0).Rows.Find(ID)
>
oDr("OfficeID") = IIf(OfficeID <Nothing, OfficeID, DBNull.Value)
>
oDr("CompanyID") = IIf(CompanyID <Nothing, CompanyID, DBNull.Value)
>
oDr("AliasID") = IIf(AliasID <Nothing, AliasID, DBNull.Value)
>
oDr("CompanyName") = IIf(CompanyName <Nothing, CompanyName,
DBNull.Value)
>
>
>
End If
>
End Sub
>
Public Function GetOutput() As String
>
Dim sb As New StringBuilder
>
For Each prop As PropertyInfo In Me.GetType.GetProperties
>
sb.Append(prop.Name & " - " & prop.GetValue(Me, Nothing) & "<br>")
>
Next
>
Return sb.ToString
>
End Function
>
Public Sub SaveChanges()
>
UpdateDataSet()
>
m_oData.SaveDataSet(m_CompanyDataset)
>
End Sub
>
#End Region
>
End Class
>
>
>




Jun 15 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: skura | last post by:
I am trying to understand how the data in sql server is stored and also regarding fill factor and page splitting. 1) My first question what is the difference between Index pages and Data pages....
4
by: mairhtin o'feannag | last post by:
Hello, I have a tablespace striped across three drives, call them 1,2,3, just to be clever. :) I allocated a lot more space (DMS) than I should have, since I didn't know a way to estimate the...
12
by: Sunny | last post by:
Hi, I need to download some web pages from a web server (most of them are not static html, but .asp pages). The content (I.e. the pure html) in the pages are not changed very often, so I'll...
8
by: moondaddy | last post by:
Are frame pages really taboo in asp.net and if so, why and what's the down side of using them? I'm trying to use user controls instead, but it seems that a lot of things were a lot easier with...
21
by: matvdl | last post by:
I have a system that was originally developed in asp - the pages are saved in SQL (there are over 10,000 pages) and saved to a temp directory in the server when requested by a client. I have...
5
by: Michael Herman \(Parallelspace\) | last post by:
1. What are some compelling solutions for using Master/Content pages with Web Pages? 2. If a content area has a web part zone with web parts, what is the user experience like when "editting" the...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
6
by: Konstantin Andreev | last post by:
Hello, all. Let the tablespace SY810T4K is almost full: --------------- db2 =list tablespaces show detail ... Name = SY810T4K Type = Database managed space Contents...
11
by: =?Utf-8?B?UGV0ZXIgSw==?= | last post by:
I am working with Visual Studio or alternately with Expression Web. I need to create about 50 aspx pages with about 1200 thumbnali images, typically arranged in three to four groups per page,...
1
by: deshaipet | last post by:
Hi friends - I created a automatic storage tablespace with a pagesize of 16 K and initial size of 64 MB. create large tablespace test_tbsp1 pagesize 16k managed by automatic storage autoresize...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.