Vertragsverwaltung-Klassenbibliothek  

clsAuswertungsparameter.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>iAuswertungparameternr</LI> </UL> Properties set after a succesful call of this method: <UL> <LI>iErrorCode</LI> <LI>iAuswertungparameternr</LI> <LI>sBezeichnung</LI> <LI>sOperator</LI> <LI>sFeldbezug</LI> <LI>sWert</LI> <LI>sParamName</LI> <LI>sParamType</LI> <LI>bAktiv</LI> <LI>daErstellt_am</LI> <LI>daMutiert_am</LI> <LI>iMutierer</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_Auswertungsparameter_SelectOne]" 
scmCmdToExecute.CommandType = CommandType.StoredProcedure 
Dim dtToReturn As DataTable = new DataTable("Auswertungsparameter") 
Dim sdaAdapter As SqlDataAdapter = new SqlDataAdapter(scmCmdToExecute) 
 
' // Use base class' connection object 
scmCmdToExecute.Connection = m_scoMainConnection 
 
Try 
scmCmdToExecute.Parameters.Add(new SqlParameter("@iAuswertungparameternr", SqlDbType.Int, 4, ParameterDirection.Input, False, 10, 0, "", DataRowVersion.Proposed, m_iAuswertungparameternr)) 
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_Auswertungsparameter_SelectOne' reported the ErrorCode: " & m_iErrorCode.ToString()) 
End If 
 
If dtToReturn.Rows.Count > 0 Then 
m_iAuswertungparameternr = New SqlInt32(CType(dtToReturn.Rows(0)("Auswertungparameternr"), Integer)) 
If dtToReturn.Rows(0)("Bezeichnung") Is System.DBNull.Value Then 
m_sBezeichnung = SqlString.Null 
Else 
m_sBezeichnung = New SqlString(CType(dtToReturn.Rows(0)("Bezeichnung"), String)) 
End If 
If dtToReturn.Rows(0)("Operator") Is System.DBNull.Value Then 
m_sOperator = SqlString.Null 
Else 
m_sOperator = New SqlString(CType(dtToReturn.Rows(0)("Operator"), String)) 
End If 
If dtToReturn.Rows(0)("Feldbezug") Is System.DBNull.Value Then 
m_sFeldbezug = SqlString.Null 
Else 
m_sFeldbezug = New SqlString(CType(dtToReturn.Rows(0)("Feldbezug"), String)) 
End If 
If dtToReturn.Rows(0)("Wert") Is System.DBNull.Value Then 
m_sWert = SqlString.Null 
Else 
m_sWert = New SqlString(CType(dtToReturn.Rows(0)("Wert"), String)) 
End If 
If dtToReturn.Rows(0)("ParamName") Is System.DBNull.Value Then 
m_sParamName = SqlString.Null 
Else 
m_sParamName = New SqlString(CType(dtToReturn.Rows(0)("ParamName"), String)) 
End If 
If dtToReturn.Rows(0)("ParamType") Is System.DBNull.Value Then 
m_sParamType = SqlString.Null 
Else 
m_sParamType = New SqlString(CType(dtToReturn.Rows(0)("ParamType"), String)) 
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 
End If 
Return dtToReturn 
Catch ex As Exception 
' // some error occured. Bubble it to caller and encapsulate Exception object 
Throw New Exception("clsAuswertungsparameter::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

clsAuswertungsparameter