7 つのオブジェクトを含むリストを読み込んでいますが、オブジェクトは最後に追加されたオブジェクトで「上書き」されます。作成される 7 つのオブジェクト (Exec、Mgr、Position... など) があります。最初の「Exec」はリストに正しく追加されますが、作成される新しい OrgShape ごとに、以前にリストに追加されたすべての OrgShapes が上書きされます。 . 私は何か簡単なものを見逃していることを知っています...
Public Shared Function GetOrgShapeData() As List(Of OrgShape)
Dim OgrShapeList As New List(Of OrgShape)
Dim conn As OleDbConnection = HR_DB.GetConnection
Dim strSQL As String
strSQL = "SELECT * FROM VisioShapeDim"
Dim selectCommand As New OleDbCommand(strSQL, conn)
Try
conn.Open()
Dim reader As OleDbDataReader = selectCommand.ExecuteReader
Dim orgshape As OrgShape
Do While reader.Read
orgshape = New OrgShape
orgshape.ShapeName = reader("ShapeName")
orgshape.ShapeWidth = reader("ShapeWidth")
orgshape.ShapeHeight = reader("ShapeHeight")
OgrShapeList.Add(orgshape)
orgshape = Nothing
Loop
reader.Close()
Catch ex As OleDbException
Throw ex
Finally
conn.Close()
End Try
Return OgrShapeList
End Function
'**OrgShape クラスを追加
Public Class OrgShape
Private Shared m_ShapeName As String
Private Shared m_ShapeWidth As Double
Private Shared m_ShapeHeight As Double
Public Sub New()
End Sub
Public Shared Property ShapeName() As String
Get
Return m_ShapeName
End Get
Set(ByVal value As String)
m_ShapeName = value
End Set
End Property
Public Shared Property ShapeWidth() As Double
Get
Return m_ShapeWidth
End Get
Set(ByVal value As Double)
m_ShapeWidth = value
End Set
End Property
Public Shared Property ShapeHeight() As Double
Get
Return m_ShapeHeight
End Get
Set(ByVal value As Double)
m_ShapeHeight = value
End Set
End Property
End Class