|
Visual Basic
|
Copy Code
]]>
|
Overrides Public Function SelectOne() As DataTable Dim scmCmdToExecute As SqlCommand = New SqlCommand() scmCmdToExecute.CommandText = "dbo.[pr_Office_Vorlage_Datei_SelectOne]" scmCmdToExecute.CommandType = CommandType.StoredProcedure Dim dtToReturn As DataTable = new DataTable("Office_Vorlage_Datei") Dim sdaAdapter As SqlDataAdapter = new SqlDataAdapter(scmCmdToExecute) ' // Use base class' connection object scmCmdToExecute.Connection = m_scoMainConnection Try scmCmdToExecute.Parameters.Add(new SqlParameter("@ioffice_vorlage_dateinr", SqlDbType.Int, 4, ParameterDirection.Input, False, 10, 0, "", DataRowVersion.Proposed, m_iOffice_vorlage_dateinr)) 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_Office_Vorlage_Datei_SelectOne' reported the ErrorCode: " & m_iErrorCode.ToString()) End If If dtToReturn.Rows.Count > 0 Then m_iOffice_vorlage_dateinr = New SqlInt32(CType(dtToReturn.Rows(0)("office_vorlage_dateinr"), Integer)) If dtToReturn.Rows(0)("office_vorlagenr") Is System.DBNull.Value Then m_iOffice_vorlagenr = SqlInt32.Null Else m_iOffice_vorlagenr = New SqlInt32(CType(dtToReturn.Rows(0)("office_vorlagenr"), Integer)) End If If dtToReturn.Rows(0)("vorlage") Is System.DBNull.Value Then m_blobVorlage = SqlBinary.Null Else m_blobVorlage = New SqlBinary(CType(dtToReturn.Rows(0)("vorlage"), Byte())) 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)("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)("freigegeben") Is System.DBNull.Value Then m_bFreigegeben = SqlBoolean.Null Else m_bFreigegeben = New SqlBoolean(CType(dtToReturn.Rows(0)("freigegeben"), Boolean)) End If If dtToReturn.Rows(0)("fragabe_am") Is System.DBNull.Value Then m_daFragabe_am = SqlDateTime.Null Else m_daFragabe_am = New SqlDateTime(CType(dtToReturn.Rows(0)("fragabe_am"), Date)) End If If dtToReturn.Rows(0)("freigabe_durch") Is System.DBNull.Value Then m_iFreigabe_durch = SqlInt32.Null Else m_iFreigabe_durch = New SqlInt32(CType(dtToReturn.Rows(0)("freigabe_durch"), Integer)) End If If dtToReturn.Rows(0)("uebernahme_produktion") Is System.DBNull.Value Then m_daUebernahme_produktion = SqlDateTime.Null Else m_daUebernahme_produktion = New SqlDateTime(CType(dtToReturn.Rows(0)("uebernahme_produktion"), Date)) End If If dtToReturn.Rows(0)("dateiname") Is System.DBNull.Value Then m_sDateiname = SqlString.Null Else m_sDateiname = New SqlString(CType(dtToReturn.Rows(0)("dateiname"), String)) End If End If Return dtToReturn Catch ex As Exception ' // some error occured. Bubble it to caller and encapsulate Exception object Throw New Exception("clsOffice_Vorlage_Datei::SelectOne::Error occured.", ex) Finally If m_bMainConnectionIsCreatedLocal Then ' // Close connection. m_scoMainConnection.Close() End If scmCmdToExecute.Dispose() sdaAdapter.Dispose() End Try End Function
|
|