Purpose: Select method. This method will Select one existing row from the database, based on the Primary Key.
[Visual Basic] Public Overrides Function SelectOne() As DataTable
DataTable object if succeeded, otherwise an Exception is thrown.
Properties needed for this method: <UL> <LI>iMitarbeitereinstellungnr</LI> </UL> Properties set after a succesful call of this method: <UL> <LI>iErrorCode</LI> <LI>iMitarbeitereinstellungnr</LI> <LI>iMitarbeiternr</LI> <LI>bVertragsuebersicht</LI> <LI>bPendenzen</LI> <LI>bAktivitaeten</LI> <LI>bApplikationsuebersicht</LI> </UL> Will fill all properties corresponding with a field in the table with the value of the row selected.
[Visual Basic] Overrides Public Function SelectOne() As DataTable
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
scmCmdToExecute.CommandText = "dbo.[pr_Mitarbeitereinstellung_SelectOne]"
scmCmdToExecute.CommandType = CommandType.StoredProcedure
Dim dtToReturn As DataTable = new DataTable("Mitarbeitereinstellung")
Dim sdaAdapter As SqlDataAdapter = new SqlDataAdapter(scmCmdToExecute)
' // Use base class' connection object
scmCmdToExecute.Connection = m_scoMainConnection
Try
scmCmdToExecute.Parameters.Add(new SqlParameter("@iMitarbeitereinstellungnr", SqlDbType.Int, 4, ParameterDirection.Input, False, 10, 0, "", DataRowVersion.Proposed, m_iMitarbeitereinstellungnr))
scmCmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, m_iErrorCode))
If m_bMainConnectionIsCreatedLocal Then
' // Open connection.
m_scoMainConnection.Open()
Else
If m_cpMainConnectionProvider.bIsTransactionPending Then
scmCmdToExecute.Transaction = m_cpMainConnectionProvider.stCurrentTransaction
End If
End If
' // Execute query.
sdaAdapter.Fill(dtToReturn)
m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, SqlInt32))
If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then
' // Throw error.
Throw New Exception("Stored Procedure 'pr_Mitarbeitereinstellung_SelectOne' reported the ErrorCode: " & m_iErrorCode.ToString())
End If
If dtToReturn.Rows.Count > 0 Then
m_iMitarbeitereinstellungnr = New SqlInt32(CType(dtToReturn.Rows(0)("Mitarbeitereinstellungnr"), Integer))
If dtToReturn.Rows(0)("Mitarbeiternr") Is System.DBNull.Value Then
m_iMitarbeiternr = SqlInt32.Null
Else
m_iMitarbeiternr = New SqlInt32(CType(dtToReturn.Rows(0)("Mitarbeiternr"), Integer))
End If
If dtToReturn.Rows(0)("Vertragsuebersicht") Is System.DBNull.Value Then
m_bVertragsuebersicht = SqlBoolean.Null
Else
m_bVertragsuebersicht = New SqlBoolean(CType(dtToReturn.Rows(0)("Vertragsuebersicht"), Boolean))
End If
If dtToReturn.Rows(0)("Pendenzen") Is System.DBNull.Value Then
m_bPendenzen = SqlBoolean.Null
Else
m_bPendenzen = New SqlBoolean(CType(dtToReturn.Rows(0)("Pendenzen"), Boolean))
End If
If dtToReturn.Rows(0)("Aktivitaeten") Is System.DBNull.Value Then
m_bAktivitaeten = SqlBoolean.Null
Else
m_bAktivitaeten = New SqlBoolean(CType(dtToReturn.Rows(0)("Aktivitaeten"), Boolean))
End If
If dtToReturn.Rows(0)("Applikationsuebersicht") Is System.DBNull.Value Then
m_bApplikationsuebersicht = SqlBoolean.Null
Else
m_bApplikationsuebersicht = New SqlBoolean(CType(dtToReturn.Rows(0)("Applikationsuebersicht"), Boolean))
End If
End If
Return dtToReturn
Catch ex As Exception
' // some error occured. Bubble it to caller and encapsulate Exception object
Throw New Exception("clsMitarbeitereinstellung::SelectOne::Error occured.", ex)
Finally
If m_bMainConnectionIsCreatedLocal Then
' // Close connection.
m_scoMainConnection.Close()
End If
scmCmdToExecute.Dispose()
sdaAdapter.Dispose()
End Try
End Function
Plattformen: Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition