У меня нет ошибок из этих частей кода, они просто пустые каждый раз. Мне интересно, возможно, я создал их неправильно. Помощь, как всегда, очень ценится;
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 есть;
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
Я получаю правильное возвращение (идентификатор строки в БД) из конечной функции - но правильные данные не вставляются, я получаю данные по умолчанию, которые я установил для Property в LogDetails. Кто-нибудь может увидеть, что я могу делать здесь не так?
Помощь очень ценится:)
По запросу:
DAL: 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