Vertragsverwaltung-Klassenbibliothek  

clsServiceKatalog_SLAKatalog.SelectOne -Methode

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

Rückgabewert

DataTable object if succeeded, otherwise an Exception is thrown.

Hinweise

Properties needed for this method: <UL> <LI>iServiceKatalog_SLAKatalognr</LI> </UL> Properties set after a succesful call of this method: <UL> <LI>iErrorCode</LI> <LI>iServiceKatalog_SLAKatalognr</LI> <LI>iServiceKatalognr</LI> <LI>iSLAKatalogNr</LI> <LI>bAktiv</LI> <LI>daErstellt_am</LI> <LI>daMutiert_am</LI> <LI>iMutierer</LI> <LI>iMandantnr</LI> </UL> Will fill all properties corresponding with a field in the table with the value of the row selected.

Quellcode

[Visual Basic]
		Overrides Public Function SelectOne() As DataTable 
Dim scmCmdToExecute As SqlCommand = New SqlCommand() 
scmCmdToExecute.CommandText = "dbo.[pr_ServiceKatalog_SLAKatalog_SelectOne]" 
scmCmdToExecute.CommandType = CommandType.StoredProcedure 
Dim dtToReturn As DataTable = new DataTable("ServiceKatalog_SLAKatalog") 
Dim sdaAdapter As SqlDataAdapter = new SqlDataAdapter(scmCmdToExecute) 
 
' // Use base class' connection object 
scmCmdToExecute.Connection = m_scoMainConnection 
 
Try 
scmCmdToExecute.Parameters.Add(new SqlParameter("@iServiceKatalog_SLAKatalognr", SqlDbType.Int, 4, ParameterDirection.Input, False, 10, 0, "", DataRowVersion.Proposed, m_iServiceKatalog_SLAKatalognr)) 
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_ServiceKatalog_SLAKatalog_SelectOne' reported the ErrorCode: " & m_iErrorCode.ToString()) 
End If 
 
If dtToReturn.Rows.Count > 0 Then 
m_iServiceKatalog_SLAKatalognr = New SqlInt32(CType(dtToReturn.Rows(0)("ServiceKatalog_SLAKatalognr"), Integer)) 
If dtToReturn.Rows(0)("ServiceKatalognr") Is System.DBNull.Value Then 
m_iServiceKatalognr = SqlInt32.Null 
Else 
m_iServiceKatalognr = New SqlInt32(CType(dtToReturn.Rows(0)("ServiceKatalognr"), Integer)) 
End If 
If dtToReturn.Rows(0)("SLAKatalogNr") Is System.DBNull.Value Then 
m_iSLAKatalogNr = SqlInt32.Null 
Else 
m_iSLAKatalogNr = New SqlInt32(CType(dtToReturn.Rows(0)("SLAKatalogNr"), Integer)) 
End If 
If dtToReturn.Rows(0)("Aktiv") Is System.DBNull.Value Then 
m_bAktiv = SqlBoolean.Null 
Else 
m_bAktiv = New SqlBoolean(CType(dtToReturn.Rows(0)("Aktiv"), Boolean)) 
End If 
If dtToReturn.Rows(0)("Erstellt_am") Is System.DBNull.Value Then 
m_daErstellt_am = SqlDateTime.Null 
Else 
m_daErstellt_am = New SqlDateTime(CType(dtToReturn.Rows(0)("Erstellt_am"), Date)) 
End If 
If dtToReturn.Rows(0)("Mutiert_am") Is System.DBNull.Value Then 
m_daMutiert_am = SqlDateTime.Null 
Else 
m_daMutiert_am = New SqlDateTime(CType(dtToReturn.Rows(0)("Mutiert_am"), Date)) 
End If 
If dtToReturn.Rows(0)("Mutierer") Is System.DBNull.Value Then 
m_iMutierer = SqlInt32.Null 
Else 
m_iMutierer = New SqlInt32(CType(dtToReturn.Rows(0)("Mutierer"), Integer)) 
End If 
If dtToReturn.Rows(0)("Mandantnr") Is System.DBNull.Value Then 
m_iMandantnr = SqlInt32.Null 
Else 
m_iMandantnr = New SqlInt32(CType(dtToReturn.Rows(0)("Mandantnr"), Integer)) 
End If 
End If 
Return dtToReturn 
Catch ex As Exception 
' // some error occured. Bubble it to caller and encapsulate Exception object 
Throw New Exception("clsServiceKatalog_SLAKatalog::SelectOne::Error occured.", ex) 
Finally 
If m_bMainConnectionIsCreatedLocal Then 
' // Close connection. 
m_scoMainConnection.Close() 
End If 
scmCmdToExecute.Dispose() 
sdaAdapter.Dispose() 
End Try 
End Function

Forderungen

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

Siehe auch

clsServiceKatalog_SLAKatalog