나는이 코드 조각들에 어떤 오류도 없으며, 매번 비어 있습니다. 내가 잘못 작성했는지 궁금합니다. 언제나처럼 도와주세요. 대단히 감사합니다.Object가 Function으로 전달되었지만 수신되지 않았습니다 ... 이유가 무엇입니까?
Dim l As New Log()
l.Log = "Attempted staff login with username [" & txtUsername.Text & "]"
l.LogId = 0
l.StaffId = 4
l.LogDate = Date.Now()
l.Insert()
.Insert()는이 두 함수에 의해 BLL 계층에서 선택됩니다.
Public Function Insert() As Integer
Return InsertLog(Me.LogId, Me.Log, Me.StaffId, Me.LogDate)
End Function
Public Shared Function InsertLog(ByVal logid As Integer, ByVal log As String, ByVal staffid As Integer, ByVal logdate As DateTime) As Integer
Using scope As New TransactionScope()
Dim record As New LogDetails(logid, log, staffid, logdate)
Dim ret As Integer = SiteProvider.Avalon.InsertLog(record)
scope.Complete()
Return ret
End Using
End Function
DAL InsertLog는 다음과 같습니다. 내가 속성의 LogDetails 내에 대해 설정 한 기본 데이터를 받고 있어요,하지만 정확한 데이터가 삽입되지 않는 -
Public Overrides Function InsertLog(ByVal log As LogDetails) As Integer
Using cn As New SqlConnection(Me.ConnectionString)
Dim cmd As New SqlCommand("sp_log_Insert", cn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@log", log.Log)
cmd.Parameters.AddWithValue("@staff_id", log.StaffId)
cmd.Parameters.AddWithValue("@log_date", log.LogDate)
Dim param As New SqlParameter
param.Direction = ParameterDirection.ReturnValue
cmd.Parameters.Add(param)
cn.Open()
Dim ret As Integer = ExecuteNonQuery(cmd)
Return CInt(Convert.ToInt32(param.Value))
End Using
End Function
나는 마지막 함수의 올바른 리턴 (DB를 행 ID)를 얻는다. 아무도 내가 여기서 잘못하고있는 것을 볼 수 있습니까?
도움말은 대단히 감사합니다 :)
요청으로 : DAL :
Public Sub New(ByVal logid As Integer, ByVal log As String, ByVal staffid As Integer, ByVal logdate As DateTime)
_logid = logid
_log = log
_staffid = staffid
_logdate = logdate
End Sub
: LogDetails
Imports Microsoft.VisualBasic
Namespace Harmony.Zizz.DAL
Public Class LogDetails
Protected _logid As Integer = 0
Protected _log As String = ""
Protected _staffid As Integer = 0
Protected _logdate As DateTime = Date.Now
Public Sub New()
End Sub
Public Sub New(ByVal logid As Integer, ByVal log As String, ByVal staffid As Integer, ByVal logdate As DateTime)
End Sub
Public Property LogId() As Integer
Get
Return _logid
End Get
Set(ByVal value As Integer)
_logid = value
End Set
End Property
Public Property Log() As String
Get
Return _log
End Get
Set(ByVal value As String)
_log = value
End Set
End Property
Public Property StaffId() As Integer
Get
Return _staffid
End Get
Set(ByVal value As Integer)
_staffid = value
End Set
End Property
Public Property LogDate() As DateTime
Get
Return _logdate
End Get
Set(ByVal value As DateTime)
_logdate = value
End Set
End Property
End Class
End Namespace
쇼 esp 레지스터 LogDetails에 대한 코드를 사용합니다. 그 생성자 – AnthonyWJones
안녕하세요 anthony, LogDetails 클래스를 추가했습니다. 이것은 DAL 내에서 가져온 것으로 BLL의 맨 위로 가져 오며 .Inserts()가 호출됩니다. 나는 또한 내 BLL에서 똑같이 보이는 Log 클래스를 가지고있다. 이것은 n- 티어 아키텍처에 대한 나의 이해를 기반으로하지만 아주 잘못 될 수도있다 ... – dooburt