473,591 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Storing a user created object as a session variable

RSH
Hi,

I have a situation where I have created an object that contains
fields,properti es and functions. After creating the object I attempted to
assign it to a session variable so i could retrieve the information it
contained on another page. This was significant because I am initially
loading the data from the database, then storing relevent information in the
object, I am allowing users to change the data then preview the
modifications on a secondary page...BEFORE they save the changes. Then if
they decide to save the changes they will go ahead and save them to a
database.

Everything seemed to be working fine until I attempted to store the object
in a session variable, when I received this error:
The error description is as follows : System.Web.Http Exception: 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'. --->
System.Runtime. Serialization.S erializationExc eption: The type
MyTimePlus.SBOC ontact in Assembly MyTimePlus, Version=1.0.268 6.13333,
Culture=neutral , PublicKeyToken= null is not marked as serializable.

Is there anyway for me to store this object in a session variable? Or do I
have to split the class into two seperate classes, one that stores the
properties and the other that manages the data management? In that case do
I use inheritance, or just let them remain two independent objects that
communicate? ...or what is the recommended way to handle this scenerio?

ASP .Net 1.1 / Session: State Server

Thanks!

Ron

Public Class SBOContact

Private m_SBONumber As String

Private m_ContactName As String

Private m_URLName As String

Private m_Phone1 As String

Private m_Phone2 As String

Private m_Phone3 As String

Private m_Phone4 As String

Private m_Phone5 As String

Private m_Phone6 As String

Private m_Phone1Label As String

Private m_Phone2Label As String

Private m_Phone3Label As String

Private m_Phone4Label As String

Private m_Phone5Label As String

Private m_Phone6Label As String

Private m_Address1 As String

Private m_Address2 As String

Private m_City As String

Private m_State As String

Private m_ZipCode As String

Private m_Email As String

#Region "Constructo r"

Public Sub New(ByVal SBONumber As String)

m_SBONumber = SBONumber

LoadData()

End Sub

#End Region

#Region "Properties "

Public Property SBONumber() As String

Get

Return m_SBONumber

End Get

Set(ByVal Value As String)

m_SBONumber = Value

End Set

End Property

Public Property ContactName() As String

Get

Return m_ContactName

End Get

Set(ByVal Value As String)

m_ContactName = Value

End Set

End Property

Public Property URLName() As String

Get

Return m_URLName

End Get

Set(ByVal Value As String)

m_URLName = Value

End Set

End Property

Public Property Phone1() As String

Get

Return m_Phone1

End Get

Set(ByVal Value As String)

m_Phone1 = Value

End Set

End Property

Public Property Phone2() As String

Get

Return m_Phone2

End Get

Set(ByVal Value As String)

m_Phone2 = Value

End Set

End Property

Public Property Phone3() As String

Get

Return m_Phone3

End Get

Set(ByVal Value As String)

m_Phone3 = Value

End Set

End Property

Public Property Phone4() As String

Get

Return m_Phone4

End Get

Set(ByVal Value As String)

m_Phone4 = Value

End Set

End Property

Public Property Phone5() As String

Get

Return m_Phone5

End Get

Set(ByVal Value As String)

m_Phone5 = Value

End Set

End Property

Public Property Phone6() As String

Get

Return m_Phone6

End Get

Set(ByVal Value As String)

m_Phone6 = Value

End Set

End Property

Public Property Phone1Label() As String

Get

Return m_Phone1Label

End Get

Set(ByVal Value As String)

m_Phone1Label = Value

End Set

End Property

Public Property Phone2Label() As String

Get

Return m_Phone2Label

End Get

Set(ByVal Value As String)

m_Phone2Label = Value

End Set

End Property

Public Property Phone3Label() As String

Get

Return m_Phone3Label

End Get

Set(ByVal Value As String)

m_Phone3Label = Value

End Set

End Property

Public Property Phone4Label() As String

Get

Return m_Phone4Label

End Get

Set(ByVal Value As String)

m_Phone4Label = Value

End Set

End Property

Public Property Phone5Label() As String

Get

Return m_Phone5Label

End Get

Set(ByVal Value As String)

m_Phone5Label = Value

End Set

End Property

Public Property Phone6Label() As String

Get

Return m_Phone6Label

End Get

Set(ByVal Value As String)

m_Phone6Label = Value

End Set

End Property

Public Property Address1() As String

Get

Return m_Address1

End Get

Set(ByVal Value As String)

m_Address1 = Value

End Set

End Property

Public Property Address2() As String

Get

Return m_Address2

End Get

Set(ByVal Value As String)

m_Address2 = Value

End Set

End Property

Public Property City() As String

Get

Return m_City

End Get

Set(ByVal Value As String)

m_City = Value

End Set

End Property

Public Property State() As String

Get

Return m_State

End Get

Set(ByVal Value As String)

m_State = Value

End Set

End Property

Public Property ZipCode() As String

Get

Return m_ZipCode

End Get

Set(ByVal Value As String)

m_ZipCode = Value

End Set

End Property

Public Property Email() As String

Get

Return m_Email

End Get

Set(ByVal Value As String)

m_Email = Value

End Set

End Property

#End Region

Private Sub LoadData()

Dim i As Integer

Dim cmdReader As SqlCommand

Dim dtrList As SqlDataReader

Dim j As Integer

Dim strSQL As String

Dim Con As SqlConnection

Con = New SqlConnection(A ppSettings("Sql Conn"))

Try

Con.Open()

strSQL = "SELECT * FROM Table WHERE SBONumber='" & m_SBONumber & "'"

cmdReader = New SqlCommand(strS QL, Con)

dtrList = cmdReader.Execu teReader

While dtrList.Read

m_SBONumber = SetValue(dtrLis t("SBONumber" ))

m_ContactName = SetValue(dtrLis t("ContactName" ))

m_URLName = SetValue(dtrLis t("URLName"))

m_Phone1 = SetValue(dtrLis t("Phone1"))

m_Phone2 = SetValue(dtrLis t("Phone2"))

m_Phone3 = SetValue(dtrLis t("Phone3"))

m_Phone4 = SetValue(dtrLis t("Phone4"))

m_Phone5 = SetValue(dtrLis t("Phone5"))

m_Phone6 = SetValue(dtrLis t("Phone6"))

m_Phone1Label = SetValue(dtrLis t("Phone1Label" ))

m_Phone2Label = SetValue(dtrLis t("Phone2Label" ))

m_Phone3Label = SetValue(dtrLis t("Phone3Label" ))

m_Phone4Label = SetValue(dtrLis t("Phone4Label" ))

m_Phone5Label = SetValue(dtrLis t("Phone5Label" ))

m_Phone6Label = SetValue(dtrLis t("Phone6Label" ))

m_Address1 = SetValue(dtrLis t("Address1") )

m_Address2 = SetValue(dtrLis t("Address2") )

m_City = SetValue(dtrLis t("City"))

m_State = SetValue(dtrLis t("State"))

m_ZipCode = SetValue(dtrLis t("ZipCode"))

m_Email = SetValue(dtrLis t("Email"))

End While

If dtrList.IsClose d = False Then dtrList.Close()

Catch exc As Exception

dim errObject as ErrorObject

errObject .HandleError(ex c)

Finally

If Con.State = ConnectionState .Open Then Con.Close()

Con = Nothing

End Try

End Sub

Private Function SetValue(ByVal Field) As String

If Not Field Is DBNull.Value Then

If Len(Trim(Field) ) 0 Then

Return Field

Else

Return ""

End If

Else

Return ""

End If

End Function

End Class
May 10 '07 #1
3 2034
Yeah. Is the session state mode in your Web.config file set to "InProc"?
It must be for this to work.

I think.
Peter

"RSH" <wa************ *@yahoo.comwrot e in message
news:eb******** *****@TK2MSFTNG P05.phx.gbl...
Hi,

I have a situation where I have created an object that contains
fields,properti es and functions. After creating the object I attempted to
assign it to a session variable so i could retrieve the information it
contained on another page. This was significant because I am initially
loading the data from the database, then storing relevent information in
the object, I am allowing users to change the data then preview the
modifications on a secondary page...BEFORE they save the changes. Then if
they decide to save the changes they will go ahead and save them to a
database.

Everything seemed to be working fine until I attempted to store the object
in a session variable, when I received this error:
The error description is as follows : System.Web.Http Exception: 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'. --->
System.Runtime. Serialization.S erializationExc eption: The type
MyTimePlus.SBOC ontact in Assembly MyTimePlus, Version=1.0.268 6.13333,
Culture=neutral , PublicKeyToken= null is not marked as serializable.

Is there anyway for me to store this object in a session variable? Or do
I have to split the class into two seperate classes, one that stores the
properties and the other that manages the data management? In that case
do I use inheritance, or just let them remain two independent objects that
communicate? ...or what is the recommended way to handle this scenerio?

ASP .Net 1.1 / Session: State Server

Thanks!

Ron

Public Class SBOContact

Private m_SBONumber As String

Private m_ContactName As String

Private m_URLName As String

Private m_Phone1 As String

Private m_Phone2 As String

Private m_Phone3 As String

Private m_Phone4 As String

Private m_Phone5 As String

Private m_Phone6 As String

Private m_Phone1Label As String

Private m_Phone2Label As String

Private m_Phone3Label As String

Private m_Phone4Label As String

Private m_Phone5Label As String

Private m_Phone6Label As String

Private m_Address1 As String

Private m_Address2 As String

Private m_City As String

Private m_State As String

Private m_ZipCode As String

Private m_Email As String

#Region "Constructo r"

Public Sub New(ByVal SBONumber As String)

m_SBONumber = SBONumber

LoadData()

End Sub

#End Region

#Region "Properties "

Public Property SBONumber() As String

Get

Return m_SBONumber

End Get

Set(ByVal Value As String)

m_SBONumber = Value

End Set

End Property

Public Property ContactName() As String

Get

Return m_ContactName

End Get

Set(ByVal Value As String)

m_ContactName = Value

End Set

End Property

Public Property URLName() As String

Get

Return m_URLName

End Get

Set(ByVal Value As String)

m_URLName = Value

End Set

End Property

Public Property Phone1() As String

Get

Return m_Phone1

End Get

Set(ByVal Value As String)

m_Phone1 = Value

End Set

End Property

Public Property Phone2() As String

Get

Return m_Phone2

End Get

Set(ByVal Value As String)

m_Phone2 = Value

End Set

End Property

Public Property Phone3() As String

Get

Return m_Phone3

End Get

Set(ByVal Value As String)

m_Phone3 = Value

End Set

End Property

Public Property Phone4() As String

Get

Return m_Phone4

End Get

Set(ByVal Value As String)

m_Phone4 = Value

End Set

End Property

Public Property Phone5() As String

Get

Return m_Phone5

End Get

Set(ByVal Value As String)

m_Phone5 = Value

End Set

End Property

Public Property Phone6() As String

Get

Return m_Phone6

End Get

Set(ByVal Value As String)

m_Phone6 = Value

End Set

End Property

Public Property Phone1Label() As String

Get

Return m_Phone1Label

End Get

Set(ByVal Value As String)

m_Phone1Label = Value

End Set

End Property

Public Property Phone2Label() As String

Get

Return m_Phone2Label

End Get

Set(ByVal Value As String)

m_Phone2Label = Value

End Set

End Property

Public Property Phone3Label() As String

Get

Return m_Phone3Label

End Get

Set(ByVal Value As String)

m_Phone3Label = Value

End Set

End Property

Public Property Phone4Label() As String

Get

Return m_Phone4Label

End Get

Set(ByVal Value As String)

m_Phone4Label = Value

End Set

End Property

Public Property Phone5Label() As String

Get

Return m_Phone5Label

End Get

Set(ByVal Value As String)

m_Phone5Label = Value

End Set

End Property

Public Property Phone6Label() As String

Get

Return m_Phone6Label

End Get

Set(ByVal Value As String)

m_Phone6Label = Value

End Set

End Property

Public Property Address1() As String

Get

Return m_Address1

End Get

Set(ByVal Value As String)

m_Address1 = Value

End Set

End Property

Public Property Address2() As String

Get

Return m_Address2

End Get

Set(ByVal Value As String)

m_Address2 = Value

End Set

End Property

Public Property City() As String

Get

Return m_City

End Get

Set(ByVal Value As String)

m_City = Value

End Set

End Property

Public Property State() As String

Get

Return m_State

End Get

Set(ByVal Value As String)

m_State = Value

End Set

End Property

Public Property ZipCode() As String

Get

Return m_ZipCode

End Get

Set(ByVal Value As String)

m_ZipCode = Value

End Set

End Property

Public Property Email() As String

Get

Return m_Email

End Get

Set(ByVal Value As String)

m_Email = Value

End Set

End Property

#End Region

Private Sub LoadData()

Dim i As Integer

Dim cmdReader As SqlCommand

Dim dtrList As SqlDataReader

Dim j As Integer

Dim strSQL As String

Dim Con As SqlConnection

Con = New SqlConnection(A ppSettings("Sql Conn"))

Try

Con.Open()

strSQL = "SELECT * FROM Table WHERE SBONumber='" & m_SBONumber & "'"

cmdReader = New SqlCommand(strS QL, Con)

dtrList = cmdReader.Execu teReader

While dtrList.Read

m_SBONumber = SetValue(dtrLis t("SBONumber" ))

m_ContactName = SetValue(dtrLis t("ContactName" ))

m_URLName = SetValue(dtrLis t("URLName"))

m_Phone1 = SetValue(dtrLis t("Phone1"))

m_Phone2 = SetValue(dtrLis t("Phone2"))

m_Phone3 = SetValue(dtrLis t("Phone3"))

m_Phone4 = SetValue(dtrLis t("Phone4"))

m_Phone5 = SetValue(dtrLis t("Phone5"))

m_Phone6 = SetValue(dtrLis t("Phone6"))

m_Phone1Label = SetValue(dtrLis t("Phone1Label" ))

m_Phone2Label = SetValue(dtrLis t("Phone2Label" ))

m_Phone3Label = SetValue(dtrLis t("Phone3Label" ))

m_Phone4Label = SetValue(dtrLis t("Phone4Label" ))

m_Phone5Label = SetValue(dtrLis t("Phone5Label" ))

m_Phone6Label = SetValue(dtrLis t("Phone6Label" ))

m_Address1 = SetValue(dtrLis t("Address1") )

m_Address2 = SetValue(dtrLis t("Address2") )

m_City = SetValue(dtrLis t("City"))

m_State = SetValue(dtrLis t("State"))

m_ZipCode = SetValue(dtrLis t("ZipCode"))

m_Email = SetValue(dtrLis t("Email"))

End While

If dtrList.IsClose d = False Then dtrList.Close()

Catch exc As Exception

dim errObject as ErrorObject

errObject .HandleError(ex c)

Finally

If Con.State = ConnectionState .Open Then Con.Close()

Con = Nothing

End Try

End Sub

Private Function SetValue(ByVal Field) As String

If Not Field Is DBNull.Value Then

If Len(Trim(Field) ) 0 Then

Return Field

Else

Return ""

End If

Else

Return ""

End If

End Function

End Class


May 10 '07 #2
Add the Serializable attribute to your class

[Serializable]

public class MyClass

"RSH" <wa************ *@yahoo.comwrot e in message
news:eb******** *****@TK2MSFTNG P05.phx.gbl...
Hi,

I have a situation where I have created an object that contains
fields,properti es and functions. After creating the object I attempted to
assign it to a session variable so i could retrieve the information it
contained on another page. This was significant because I am initially
loading the data from the database, then storing relevent information in
the object, I am allowing users to change the data then preview the
modifications on a secondary page...BEFORE they save the changes. Then if
they decide to save the changes they will go ahead and save them to a
database.

Everything seemed to be working fine until I attempted to store the object
in a session variable, when I received this error:
The error description is as follows : System.Web.Http Exception: 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'. --->
System.Runtime. Serialization.S erializationExc eption: The type
MyTimePlus.SBOC ontact in Assembly MyTimePlus, Version=1.0.268 6.13333,
Culture=neutral , PublicKeyToken= null is not marked as serializable.

Is there anyway for me to store this object in a session variable? Or do
I have to split the class into two seperate classes, one that stores the
properties and the other that manages the data management? In that case
do I use inheritance, or just let them remain two independent objects that
communicate? ...or what is the recommended way to handle this scenerio?

ASP .Net 1.1 / Session: State Server

Thanks!

Ron

Public Class SBOContact

Private m_SBONumber As String

Private m_ContactName As String

Private m_URLName As String

Private m_Phone1 As String

Private m_Phone2 As String

Private m_Phone3 As String

Private m_Phone4 As String

Private m_Phone5 As String

Private m_Phone6 As String

Private m_Phone1Label As String

Private m_Phone2Label As String

Private m_Phone3Label As String

Private m_Phone4Label As String

Private m_Phone5Label As String

Private m_Phone6Label As String

Private m_Address1 As String

Private m_Address2 As String

Private m_City As String

Private m_State As String

Private m_ZipCode As String

Private m_Email As String

#Region "Constructo r"

Public Sub New(ByVal SBONumber As String)

m_SBONumber = SBONumber

LoadData()

End Sub

#End Region

#Region "Properties "

Public Property SBONumber() As String

Get

Return m_SBONumber

End Get

Set(ByVal Value As String)

m_SBONumber = Value

End Set

End Property

Public Property ContactName() As String

Get

Return m_ContactName

End Get

Set(ByVal Value As String)

m_ContactName = Value

End Set

End Property

Public Property URLName() As String

Get

Return m_URLName

End Get

Set(ByVal Value As String)

m_URLName = Value

End Set

End Property

Public Property Phone1() As String

Get

Return m_Phone1

End Get

Set(ByVal Value As String)

m_Phone1 = Value

End Set

End Property

Public Property Phone2() As String

Get

Return m_Phone2

End Get

Set(ByVal Value As String)

m_Phone2 = Value

End Set

End Property

Public Property Phone3() As String

Get

Return m_Phone3

End Get

Set(ByVal Value As String)

m_Phone3 = Value

End Set

End Property

Public Property Phone4() As String

Get

Return m_Phone4

End Get

Set(ByVal Value As String)

m_Phone4 = Value

End Set

End Property

Public Property Phone5() As String

Get

Return m_Phone5

End Get

Set(ByVal Value As String)

m_Phone5 = Value

End Set

End Property

Public Property Phone6() As String

Get

Return m_Phone6

End Get

Set(ByVal Value As String)

m_Phone6 = Value

End Set

End Property

Public Property Phone1Label() As String

Get

Return m_Phone1Label

End Get

Set(ByVal Value As String)

m_Phone1Label = Value

End Set

End Property

Public Property Phone2Label() As String

Get

Return m_Phone2Label

End Get

Set(ByVal Value As String)

m_Phone2Label = Value

End Set

End Property

Public Property Phone3Label() As String

Get

Return m_Phone3Label

End Get

Set(ByVal Value As String)

m_Phone3Label = Value

End Set

End Property

Public Property Phone4Label() As String

Get

Return m_Phone4Label

End Get

Set(ByVal Value As String)

m_Phone4Label = Value

End Set

End Property

Public Property Phone5Label() As String

Get

Return m_Phone5Label

End Get

Set(ByVal Value As String)

m_Phone5Label = Value

End Set

End Property

Public Property Phone6Label() As String

Get

Return m_Phone6Label

End Get

Set(ByVal Value As String)

m_Phone6Label = Value

End Set

End Property

Public Property Address1() As String

Get

Return m_Address1

End Get

Set(ByVal Value As String)

m_Address1 = Value

End Set

End Property

Public Property Address2() As String

Get

Return m_Address2

End Get

Set(ByVal Value As String)

m_Address2 = Value

End Set

End Property

Public Property City() As String

Get

Return m_City

End Get

Set(ByVal Value As String)

m_City = Value

End Set

End Property

Public Property State() As String

Get

Return m_State

End Get

Set(ByVal Value As String)

m_State = Value

End Set

End Property

Public Property ZipCode() As String

Get

Return m_ZipCode

End Get

Set(ByVal Value As String)

m_ZipCode = Value

End Set

End Property

Public Property Email() As String

Get

Return m_Email

End Get

Set(ByVal Value As String)

m_Email = Value

End Set

End Property

#End Region

Private Sub LoadData()

Dim i As Integer

Dim cmdReader As SqlCommand

Dim dtrList As SqlDataReader

Dim j As Integer

Dim strSQL As String

Dim Con As SqlConnection

Con = New SqlConnection(A ppSettings("Sql Conn"))

Try

Con.Open()

strSQL = "SELECT * FROM Table WHERE SBONumber='" & m_SBONumber & "'"

cmdReader = New SqlCommand(strS QL, Con)

dtrList = cmdReader.Execu teReader

While dtrList.Read

m_SBONumber = SetValue(dtrLis t("SBONumber" ))

m_ContactName = SetValue(dtrLis t("ContactName" ))

m_URLName = SetValue(dtrLis t("URLName"))

m_Phone1 = SetValue(dtrLis t("Phone1"))

m_Phone2 = SetValue(dtrLis t("Phone2"))

m_Phone3 = SetValue(dtrLis t("Phone3"))

m_Phone4 = SetValue(dtrLis t("Phone4"))

m_Phone5 = SetValue(dtrLis t("Phone5"))

m_Phone6 = SetValue(dtrLis t("Phone6"))

m_Phone1Label = SetValue(dtrLis t("Phone1Label" ))

m_Phone2Label = SetValue(dtrLis t("Phone2Label" ))

m_Phone3Label = SetValue(dtrLis t("Phone3Label" ))

m_Phone4Label = SetValue(dtrLis t("Phone4Label" ))

m_Phone5Label = SetValue(dtrLis t("Phone5Label" ))

m_Phone6Label = SetValue(dtrLis t("Phone6Label" ))

m_Address1 = SetValue(dtrLis t("Address1") )

m_Address2 = SetValue(dtrLis t("Address2") )

m_City = SetValue(dtrLis t("City"))

m_State = SetValue(dtrLis t("State"))

m_ZipCode = SetValue(dtrLis t("ZipCode"))

m_Email = SetValue(dtrLis t("Email"))

End While

If dtrList.IsClose d = False Then dtrList.Close()

Catch exc As Exception

dim errObject as ErrorObject

errObject .HandleError(ex c)

Finally

If Con.State = ConnectionState .Open Then Con.Close()

Con = Nothing

End Try

End Sub

Private Function SetValue(ByVal Field) As String

If Not Field Is DBNull.Value Then

If Len(Trim(Field) ) 0 Then

Return Field

Else

Return ""

End If

Else

Return ""

End If

End Function

End Class


May 10 '07 #3

When using Sql Server/In Proc session caching mechanism(s), the objects need
to be serialiable.
(with sql server, remember the object is being persisted to a database, so
it has to be serializable).
You might be interested in this:

10/24/2005
Web Session Wrapper for storing and retrieving objects
http://sholliday.spaces.live.com/blog/


"RSH" <wa************ *@yahoo.comwrot e in message
news:eb******** *****@TK2MSFTNG P05.phx.gbl...
Hi,

I have a situation where I have created an object that contains
fields,properti es and functions. After creating the object I attempted to
assign it to a session variable so i could retrieve the information it
contained on another page. This was significant because I am initially
loading the data from the database, then storing relevent information in
the
object, I am allowing users to change the data then preview the
modifications on a secondary page...BEFORE they save the changes. Then if
they decide to save the changes they will go ahead and save them to a
database.

Everything seemed to be working fine until I attempted to store the object
in a session variable, when I received this error:
The error description is as follows : System.Web.Http Exception: 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'. --->
System.Runtime. Serialization.S erializationExc eption: The type
MyTimePlus.SBOC ontact in Assembly MyTimePlus, Version=1.0.268 6.13333,
Culture=neutral , PublicKeyToken= null is not marked as serializable.

Is there anyway for me to store this object in a session variable? Or do
I
have to split the class into two seperate classes, one that stores the
properties and the other that manages the data management? In that case
do
I use inheritance, or just let them remain two independent objects that
communicate? ...or what is the recommended way to handle this scenerio?

ASP .Net 1.1 / Session: State Server

Thanks!

Ron

Public Class SBOContact

Private m_SBONumber As String

Private m_ContactName As String

Private m_URLName As String

Private m_Phone1 As String

Private m_Phone2 As String

Private m_Phone3 As String

Private m_Phone4 As String

Private m_Phone5 As String

Private m_Phone6 As String

Private m_Phone1Label As String

Private m_Phone2Label As String

Private m_Phone3Label As String

Private m_Phone4Label As String

Private m_Phone5Label As String

Private m_Phone6Label As String

Private m_Address1 As String

Private m_Address2 As String

Private m_City As String

Private m_State As String

Private m_ZipCode As String

Private m_Email As String

#Region "Constructo r"

Public Sub New(ByVal SBONumber As String)

m_SBONumber = SBONumber

LoadData()

End Sub

#End Region

#Region "Properties "

Public Property SBONumber() As String

Get

Return m_SBONumber

End Get

Set(ByVal Value As String)

m_SBONumber = Value

End Set

End Property

Public Property ContactName() As String

Get

Return m_ContactName

End Get

Set(ByVal Value As String)

m_ContactName = Value

End Set

End Property

Public Property URLName() As String

Get

Return m_URLName

End Get

Set(ByVal Value As String)

m_URLName = Value

End Set

End Property

Public Property Phone1() As String

Get

Return m_Phone1

End Get

Set(ByVal Value As String)

m_Phone1 = Value

End Set

End Property

Public Property Phone2() As String

Get

Return m_Phone2

End Get

Set(ByVal Value As String)

m_Phone2 = Value

End Set

End Property

Public Property Phone3() As String

Get

Return m_Phone3

End Get

Set(ByVal Value As String)

m_Phone3 = Value

End Set

End Property

Public Property Phone4() As String

Get

Return m_Phone4

End Get

Set(ByVal Value As String)

m_Phone4 = Value

End Set

End Property

Public Property Phone5() As String

Get

Return m_Phone5

End Get

Set(ByVal Value As String)

m_Phone5 = Value

End Set

End Property

Public Property Phone6() As String

Get

Return m_Phone6

End Get

Set(ByVal Value As String)

m_Phone6 = Value

End Set

End Property

Public Property Phone1Label() As String

Get

Return m_Phone1Label

End Get

Set(ByVal Value As String)

m_Phone1Label = Value

End Set

End Property

Public Property Phone2Label() As String

Get

Return m_Phone2Label

End Get

Set(ByVal Value As String)

m_Phone2Label = Value

End Set

End Property

Public Property Phone3Label() As String

Get

Return m_Phone3Label

End Get

Set(ByVal Value As String)

m_Phone3Label = Value

End Set

End Property

Public Property Phone4Label() As String

Get

Return m_Phone4Label

End Get

Set(ByVal Value As String)

m_Phone4Label = Value

End Set

End Property

Public Property Phone5Label() As String

Get

Return m_Phone5Label

End Get

Set(ByVal Value As String)

m_Phone5Label = Value

End Set

End Property

Public Property Phone6Label() As String

Get

Return m_Phone6Label

End Get

Set(ByVal Value As String)

m_Phone6Label = Value

End Set

End Property

Public Property Address1() As String

Get

Return m_Address1

End Get

Set(ByVal Value As String)

m_Address1 = Value

End Set

End Property

Public Property Address2() As String

Get

Return m_Address2

End Get

Set(ByVal Value As String)

m_Address2 = Value

End Set

End Property

Public Property City() As String

Get

Return m_City

End Get

Set(ByVal Value As String)

m_City = Value

End Set

End Property

Public Property State() As String

Get

Return m_State

End Get

Set(ByVal Value As String)

m_State = Value

End Set

End Property

Public Property ZipCode() As String

Get

Return m_ZipCode

End Get

Set(ByVal Value As String)

m_ZipCode = Value

End Set

End Property

Public Property Email() As String

Get

Return m_Email

End Get

Set(ByVal Value As String)

m_Email = Value

End Set

End Property

#End Region

Private Sub LoadData()

Dim i As Integer

Dim cmdReader As SqlCommand

Dim dtrList As SqlDataReader

Dim j As Integer

Dim strSQL As String

Dim Con As SqlConnection

Con = New SqlConnection(A ppSettings("Sql Conn"))

Try

Con.Open()

strSQL = "SELECT * FROM Table WHERE SBONumber='" & m_SBONumber & "'"

cmdReader = New SqlCommand(strS QL, Con)

dtrList = cmdReader.Execu teReader

While dtrList.Read

m_SBONumber = SetValue(dtrLis t("SBONumber" ))

m_ContactName = SetValue(dtrLis t("ContactName" ))

m_URLName = SetValue(dtrLis t("URLName"))

m_Phone1 = SetValue(dtrLis t("Phone1"))

m_Phone2 = SetValue(dtrLis t("Phone2"))

m_Phone3 = SetValue(dtrLis t("Phone3"))

m_Phone4 = SetValue(dtrLis t("Phone4"))

m_Phone5 = SetValue(dtrLis t("Phone5"))

m_Phone6 = SetValue(dtrLis t("Phone6"))

m_Phone1Label = SetValue(dtrLis t("Phone1Label" ))

m_Phone2Label = SetValue(dtrLis t("Phone2Label" ))

m_Phone3Label = SetValue(dtrLis t("Phone3Label" ))

m_Phone4Label = SetValue(dtrLis t("Phone4Label" ))

m_Phone5Label = SetValue(dtrLis t("Phone5Label" ))

m_Phone6Label = SetValue(dtrLis t("Phone6Label" ))

m_Address1 = SetValue(dtrLis t("Address1") )

m_Address2 = SetValue(dtrLis t("Address2") )

m_City = SetValue(dtrLis t("City"))

m_State = SetValue(dtrLis t("State"))

m_ZipCode = SetValue(dtrLis t("ZipCode"))

m_Email = SetValue(dtrLis t("Email"))

End While

If dtrList.IsClose d = False Then dtrList.Close()

Catch exc As Exception

dim errObject as ErrorObject

errObject .HandleError(ex c)

Finally

If Con.State = ConnectionState .Open Then Con.Close()

Con = Nothing

End Try

End Sub

Private Function SetValue(ByVal Field) As String

If Not Field Is DBNull.Value Then

If Len(Trim(Field) ) 0 Then

Return Field

Else

Return ""

End If

Else

Return ""

End If

End Function

End Class


May 14 '07 #4

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

Similar topics

3
1774
by: Sean | last post by:
HI, I have a shopping cart in which I am trying to use breadcrumb style navgiation. I need to be able to display the categroy heading relating to the section of the site a visitor is using i.e If a user is in the "camera" section I need to display that heading as a link "camera", however in order to do this at the moment I am querying the database and storing the recordset in the application object (see below). I should imaging there is...
3
1442
by: yop | last post by:
Hello I have an application, Login page, enter UserName & Password. Function in Users called GetUserDetails and checks the details and if they are valid calls a function to fill the following in the class component called Public Class UserDetails Public UserID As Integer
0
1102
by: Sandra | last post by:
I am using a VB6 COM object with an asp.net project. I am storing the COM object in a session variable but am having a problem accessing the COM object from the session variable. I am getting the error: QueryInterface for interface object.class failed I am able to create new instances of the object with no problems but as soon as I cast the session variable to the object like so: CType(Session("object"),object.class)
2
2379
by: Shyam | last post by:
Hi, I wanted some advice on the following. All the users who log in to the system are created in the SQL Server. As I am not keen to store any user information on the web.config file for security considerations and I need to use SQL logins for each user, I decided to create a class CurrentUserClass (some what similar to the TTUser class in microsoft's ASP.NET sample Time Track application) with properties like Name, First Name, LastName,...
2
1703
by: Curt tabor | last post by:
Hi, I have several pages in my app that all use the same oleDBConnection(s). When this connection gets created, I store it as a Session variable so that other pages can access it w/o having recreate new connections every time they load. I noticed during development that when ever the app first started, the connection would not be in Session when I navigvated to a page that used it. But with subsequent calls everything would be fine and...
10
2162
by: Mark Rae | last post by:
Hi, This relates to the previous thread "Disappearing Sessions", but is a bit more generic so I thought I'd start a new thread. This one relates to the storing of objects in Session once only to prevent the system having to constantly query the database for the same information. I'm currently upgrading a v1.1 app to v2 (that's all I seem to do these days!), and it contains a class called CUser which holds details of the currently...
1
2814
by: None | last post by:
Hi, I have developed webshop application using asp.net 1.1. I'm using DataGrid in one of the pages of my site. During the page load the DataGrid will be binded by around 7500 products(rows). At the same time i'm storing the DataSet object in the Session Variable for later refinement. I'm using StateServer mode for storeing the session values. But in my server the W3wp.exe is taking 90 - 100 % CPU
2
23790
by: Anthony Smith | last post by:
I have read the message boards in this group and others. I still have not been able to pull my obect out of a session and use it. Here is how I store it in a session: <? //Include the UserClass & RoleClass so that we can create a user object. require_once("UserClass.php"); require_once("RoleClass.php");
6
17117
by: J055 | last post by:
Hi I have the following code. I upload an XML file using the FileUpload object, store the stream in a session so the user gets the chance to confirm some options then pass the stream from the Session to an XmlReader. if (performImport == false) { Session = fileUpload1.FileContent; //... some other code
0
7934
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
7992
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8225
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5732
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5400
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3891
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1465
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1199
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.