473,508 Members | 2,303 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,properties 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.HttpException: 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.SerializationExceptio n: The type
MyTimePlus.SBOContact in Assembly MyTimePlus, Version=1.0.2686.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 "Constructor"

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(AppSettings("SqlConn"))

Try

Con.Open()

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

cmdReader = New SqlCommand(strSQL, Con)

dtrList = cmdReader.ExecuteReader

While dtrList.Read

m_SBONumber = SetValue(dtrList("SBONumber"))

m_ContactName = SetValue(dtrList("ContactName"))

m_URLName = SetValue(dtrList("URLName"))

m_Phone1 = SetValue(dtrList("Phone1"))

m_Phone2 = SetValue(dtrList("Phone2"))

m_Phone3 = SetValue(dtrList("Phone3"))

m_Phone4 = SetValue(dtrList("Phone4"))

m_Phone5 = SetValue(dtrList("Phone5"))

m_Phone6 = SetValue(dtrList("Phone6"))

m_Phone1Label = SetValue(dtrList("Phone1Label"))

m_Phone2Label = SetValue(dtrList("Phone2Label"))

m_Phone3Label = SetValue(dtrList("Phone3Label"))

m_Phone4Label = SetValue(dtrList("Phone4Label"))

m_Phone5Label = SetValue(dtrList("Phone5Label"))

m_Phone6Label = SetValue(dtrList("Phone6Label"))

m_Address1 = SetValue(dtrList("Address1"))

m_Address2 = SetValue(dtrList("Address2"))

m_City = SetValue(dtrList("City"))

m_State = SetValue(dtrList("State"))

m_ZipCode = SetValue(dtrList("ZipCode"))

m_Email = SetValue(dtrList("Email"))

End While

If dtrList.IsClosed = False Then dtrList.Close()

Catch exc As Exception

dim errObject as ErrorObject

errObject .HandleError(exc)

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 2029
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.comwrote in message
news:eb*************@TK2MSFTNGP05.phx.gbl...
Hi,

I have a situation where I have created an object that contains
fields,properties 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.HttpException: 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.SerializationExceptio n: The type
MyTimePlus.SBOContact in Assembly MyTimePlus, Version=1.0.2686.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 "Constructor"

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(AppSettings("SqlConn"))

Try

Con.Open()

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

cmdReader = New SqlCommand(strSQL, Con)

dtrList = cmdReader.ExecuteReader

While dtrList.Read

m_SBONumber = SetValue(dtrList("SBONumber"))

m_ContactName = SetValue(dtrList("ContactName"))

m_URLName = SetValue(dtrList("URLName"))

m_Phone1 = SetValue(dtrList("Phone1"))

m_Phone2 = SetValue(dtrList("Phone2"))

m_Phone3 = SetValue(dtrList("Phone3"))

m_Phone4 = SetValue(dtrList("Phone4"))

m_Phone5 = SetValue(dtrList("Phone5"))

m_Phone6 = SetValue(dtrList("Phone6"))

m_Phone1Label = SetValue(dtrList("Phone1Label"))

m_Phone2Label = SetValue(dtrList("Phone2Label"))

m_Phone3Label = SetValue(dtrList("Phone3Label"))

m_Phone4Label = SetValue(dtrList("Phone4Label"))

m_Phone5Label = SetValue(dtrList("Phone5Label"))

m_Phone6Label = SetValue(dtrList("Phone6Label"))

m_Address1 = SetValue(dtrList("Address1"))

m_Address2 = SetValue(dtrList("Address2"))

m_City = SetValue(dtrList("City"))

m_State = SetValue(dtrList("State"))

m_ZipCode = SetValue(dtrList("ZipCode"))

m_Email = SetValue(dtrList("Email"))

End While

If dtrList.IsClosed = False Then dtrList.Close()

Catch exc As Exception

dim errObject as ErrorObject

errObject .HandleError(exc)

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.comwrote in message
news:eb*************@TK2MSFTNGP05.phx.gbl...
Hi,

I have a situation where I have created an object that contains
fields,properties 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.HttpException: 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.SerializationExceptio n: The type
MyTimePlus.SBOContact in Assembly MyTimePlus, Version=1.0.2686.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 "Constructor"

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(AppSettings("SqlConn"))

Try

Con.Open()

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

cmdReader = New SqlCommand(strSQL, Con)

dtrList = cmdReader.ExecuteReader

While dtrList.Read

m_SBONumber = SetValue(dtrList("SBONumber"))

m_ContactName = SetValue(dtrList("ContactName"))

m_URLName = SetValue(dtrList("URLName"))

m_Phone1 = SetValue(dtrList("Phone1"))

m_Phone2 = SetValue(dtrList("Phone2"))

m_Phone3 = SetValue(dtrList("Phone3"))

m_Phone4 = SetValue(dtrList("Phone4"))

m_Phone5 = SetValue(dtrList("Phone5"))

m_Phone6 = SetValue(dtrList("Phone6"))

m_Phone1Label = SetValue(dtrList("Phone1Label"))

m_Phone2Label = SetValue(dtrList("Phone2Label"))

m_Phone3Label = SetValue(dtrList("Phone3Label"))

m_Phone4Label = SetValue(dtrList("Phone4Label"))

m_Phone5Label = SetValue(dtrList("Phone5Label"))

m_Phone6Label = SetValue(dtrList("Phone6Label"))

m_Address1 = SetValue(dtrList("Address1"))

m_Address2 = SetValue(dtrList("Address2"))

m_City = SetValue(dtrList("City"))

m_State = SetValue(dtrList("State"))

m_ZipCode = SetValue(dtrList("ZipCode"))

m_Email = SetValue(dtrList("Email"))

End While

If dtrList.IsClosed = False Then dtrList.Close()

Catch exc As Exception

dim errObject as ErrorObject

errObject .HandleError(exc)

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.comwrote in message
news:eb*************@TK2MSFTNGP05.phx.gbl...
Hi,

I have a situation where I have created an object that contains
fields,properties 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.HttpException: 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.SerializationExceptio n: The type
MyTimePlus.SBOContact in Assembly MyTimePlus, Version=1.0.2686.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 "Constructor"

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(AppSettings("SqlConn"))

Try

Con.Open()

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

cmdReader = New SqlCommand(strSQL, Con)

dtrList = cmdReader.ExecuteReader

While dtrList.Read

m_SBONumber = SetValue(dtrList("SBONumber"))

m_ContactName = SetValue(dtrList("ContactName"))

m_URLName = SetValue(dtrList("URLName"))

m_Phone1 = SetValue(dtrList("Phone1"))

m_Phone2 = SetValue(dtrList("Phone2"))

m_Phone3 = SetValue(dtrList("Phone3"))

m_Phone4 = SetValue(dtrList("Phone4"))

m_Phone5 = SetValue(dtrList("Phone5"))

m_Phone6 = SetValue(dtrList("Phone6"))

m_Phone1Label = SetValue(dtrList("Phone1Label"))

m_Phone2Label = SetValue(dtrList("Phone2Label"))

m_Phone3Label = SetValue(dtrList("Phone3Label"))

m_Phone4Label = SetValue(dtrList("Phone4Label"))

m_Phone5Label = SetValue(dtrList("Phone5Label"))

m_Phone6Label = SetValue(dtrList("Phone6Label"))

m_Address1 = SetValue(dtrList("Address1"))

m_Address2 = SetValue(dtrList("Address2"))

m_City = SetValue(dtrList("City"))

m_State = SetValue(dtrList("State"))

m_ZipCode = SetValue(dtrList("ZipCode"))

m_Email = SetValue(dtrList("Email"))

End While

If dtrList.IsClosed = False Then dtrList.Close()

Catch exc As Exception

dim errObject as ErrorObject

errObject .HandleError(exc)

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
1759
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...
3
1435
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...
0
1095
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...
2
2373
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...
2
1701
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...
10
2148
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...
1
2803
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...
2
23786
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...
6
17103
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...
0
7224
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,...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7039
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...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1553
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 ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
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...

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.