Peter Duniho said:
You should post a concise-but-complete example of code that reliably
demonstrates the problem.
That said, it seems clear that since the two methods produce different
behavior, they obviously aren't accessing the same variable. Without
seeing the code, it's impossible to say what the confusion is.
Pete
Pete For a moment I thought it were different variable because i was using
shared methods and a shared field but i changed that and instanciated the
class to be sure that it is the same variable i'm using but that didn't solve
the problem.
Then I tried to put the data getting from my get-method in a session
variable. When i call my put(save) method i cast the session variable to the
wright type but at the point of entering my method i loose all data. The
casting etc. works fine.
Here's some of the code.
It's a web-application that calls data from a database over a business layer.
WebPage-code:
Private Sub commissionToPay(ByVal calculationDate As Date)
Try
Dim result As DataTable
Dim isSaved As Boolean
If Session("Commission") Is Nothing Then
Session("Commission") = BL.getCommissionToPay(calculationDate, isSaved)
End If
If Not Session("Commission") Is Nothing AndAlso
Session("Commission").containskey(calculationDate) Then
If Session("Commission").ContainsKey("CommissionsToPay") Then
result = CType(Session("Commission")("CommissionsToPay"),
DataSet).Tables(0)
result.DefaultView.Sort = "EmployeeName"
dtgAll.DataSource = result.DefaultView
dtgAll.DataBind()
pnlAll.Visible = True
btnAcceptToPay.Visible = Not isSaved
btnExport.Visible = False
lblHdAllEmployeeID.Visible = True
End If
Else
lblError.Text = rStrings.GetString("NoResults")
End If
Catch ex As Exception
lblError.Text = ex.Message
lblError.Visible = True
pnlMsg.Visible = True
End Try
End Sub
Private Sub btnAcceptToPay_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnAcceptToPay.Click
'Save commission and orders for faster generation of reports.
Try
Dim ht As Hashtable
ht = CType(Session("Commission"), Hashtable)
If BL.saveAcceptCommissionToPay(ht) Then
btnAcceptToPay.Visible = False
End If
Catch ex As Exception
lblError.Text = ex.Message
lblError.Visible = True
pnlMsg.Visible = True
End Try
End Sub
BL-code(partial)
Public Shared Function getCommissionToPay(ByVal calculationdate As Date,
ByRef isSaved As Boolean) As Hashtable
Dim result As DataSet
Dim htCommissions As Hashtable
Try
'First check if commission not saved yet.
result = DAL.Commission.getCommissionToPayOnDate(calculationdate)
If Not result Is Nothing Then
isSaved = True
htCommissions.Add("CommissionsToPay", result)
Return htCommissions
Else
isSaved = False
result = New DataSet
'check if result in cache
If _htCommissions Is Nothing OrElse _CalculatedFor <> calculationdate Then
htCommissions = getCommission(calculationdate)
Else
htCommissions = _htCommissions
End If
Catch ex As Exception
Throw
End Try
End Function
Public Shared Function saveAcceptCommissionToPay(ByVal ht As Hashtable) As
Boolean '(ByVal commissionData As Hashtable) As Boolean
Dim succesfull As Boolean = False
Dim CommissionToPay As DataSet
Dim commission As dsCommissions
Dim pcID, pcOrderID As Int64
Dim target As dsCommissions.TargetsRow
Dim realised As dsCommissions.SalesCountersRow
Dim corr As dsCommissions.OrderCorrectionRow
'Dim = _htCommissions
'Table0 = totals of commission and corrections
'table1 = total of corrections for 1 month
'Table2 = periods to print report
Try
'save totals & corrections
If Not ht Is Nothing Then
If ht.ContainsKey("CommissionToPay") Then
CommissionToPay = ht("CommissionToPay")
when i get in this method then the parameter ht display the value
{length=error: cannot obtain value) where at the point of casting it sais
{length=2}