views:

24

answers:

2

So in my window onLoad method I am pre-populating a grid with values retrieved from a database. Here is the method below for the window load:

Private Sub winMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ''#Load Grid
        Dim dt As New DataTable
        With dt
            .Columns.Add("Name")
            .Columns.Add("Frequency")
            .Columns.Add("Percent Spent")
            .Columns.Add("Started")
            .Columns.Add("Ends")
        End With

        Dim Budgets As New List(Of BudgetManager.DTO.Budget)
        Budgets = BudgetManager.Process.Budget.GetAllBudgets()

        Dim values(5) As String
        For Each budget In Budgets
            values(0) = budget.Name
            values(1) = BudgetManager.Lookup.GetLookupTextById(budget.FrequencyId)
            Dim total As Double = 0.0
            Dim spent As Double = 0.0
            For Each category In budget.Categories
                total += category.Amount
                spent += category.Spent
            Next
            values(2) = FormatPercent(spent / total)
            values(3) = budget.StartDate.ToString
            values(4) = budget.EndDate.ToString

            dt.Rows.Add(values)
        Next

        gridBudget.DataSource = dt
    End Sub

What happens is, when I press F5 to debug, the program loads, and the grid is still empty, just as it is without a datasource. When I try to step through the code, it actually reaches down to the line that reads

Budgets = BudgetManager.Process.Budget.GetAllBudgets()

and then stepping over this line...the window loads and it doesn't go any further in the method. What the line of code above does is eventually make a execution call of some SQL to a SQLite database, and the code gets to the point at which it calls the execute method, but doesn't even make the query yet. All the objects up until that point in the code are set properly as well (found through debugging and checking locals.)

What could be happening?

Edit:

Exception is this:

"Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

What the hell does this mean? Ha

A: 

Best guess: your sqllite execute method fails and you have a global exception handler that's eating the error.

Joel Coehoorn
Stepping through though it never even reaches the inside of the method. It fails on the call.
Scott
@Scott - try stepping into the line rather than stepping over it.
Joel Coehoorn
@Scott I suggest you write a unit test to test BudgetManager.Process.Budget.GetAllBudgets() is working as expected.
Tim Murphy
A: 

If you manually added the column names to the Datagrid in the design mode then make sure the field names match those that are returning from the db, in this case your datatable.

You could also try binding the list directly

gridBudget.DataSource = BudgetManager.Process.Budget.GetAllBudgets(Of BudgetManager.DTO.Budget)()
Saif Khan