Vertragsverwaltung-Klassenbibliothek  

clsMyKey_Tabelle.get_dbkey -Methode

[Visual Basic]
Public Function get_dbkey( _ 
ByVal Tablename As String
) As Long

Parameter

Tablename

Quellcode

[Visual Basic]
        Public Function get_dbkey(ByVal Tablename As String) As Long 
Dim m_dbkey As Long 
Dim scmCmdToExecute As SqlCommand = New SqlCommand() 
scmCmdToExecute.CommandText = "dbo.[sp_get_dbkey]" 
scmCmdToExecute.CommandType = CommandType.StoredProcedure 
' // Use base class' connection object 
scmCmdToExecute.Connection = m_scoMainConnection 
Try 
scmCmdToExecute.Parameters.Add(New SqlParameter("@Tablename", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, Tablename)) 
scmCmdToExecute.Parameters.Add(New SqlParameter("@dbkey", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, m_dbkey)) 
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. 
Try 
scmCmdToExecute.Connection.Open() 
Catch ex As Exception 
Finally 
End Try 
 
scmCmdToExecute.ExecuteNonQuery() 
m_dbkey = scmCmdToExecute.Parameters.Item("@dbkey").Value 
m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, SqlInt32)) 
scmCmdToExecute.Connection.Close() 
 
If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then 
' // Throw error. 
Throw New Exception("Stored Procedure 'sp_get_dbkey' reported the ErrorCode: " & m_iErrorCode.ToString()) 
End If 
 
Return m_dbkey 
Catch ex As Exception 
' // some error occured. Bubble it to caller and encapsulate Exception object 
Throw New Exception("clsKey_tabelle::get_dbkey::Error occured." + ex.Message, ex) 
Finally 
If m_bMainConnectionIsCreatedLocal Then 
' // Close connection. 
m_scoMainConnection.Close() 
End If 
scmCmdToExecute.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

clsMyKey_Tabelle