Click here to Skip to main content
16,013,338 members

Comments by Member 13954123 (Top 8 by date)

Member 13954123 22-Apr-19 15:26pm View    
It is a WindowsForm App.


Maybe I made some mistake, because the original app (C#) I mentioned is WPF, and my VB.NET application is WinForm. I was a little confused about which properties have the same meaning in the WinForm, since is no exactly the same names.
Member 13954123 22-Apr-19 13:52pm View    
I think so. I have set just like your example.

dateDropDown.DataSource = payments '.ItemsSource = payments
dateDropDown.DisplayMember = "DatePayment" '.DisplayMemberPath = "Date"
dateDropDown.ValueMember = "Id"

But I also set the client combobox to:
ClientDropDown.ItemsSource = clients
ClientDropDown.DisplayMemberPath = "Name"
ClientDropDown.SelectedValuePath = "Id"

Maybe is this the cause?
Member 13954123 22-Apr-19 12:41pm View    
I am not understanding why the message error refers to CLientModel. The code seems to be referring to the PaymentModel as I look.
Member 13954123 22-Apr-19 12:32pm View    
Actually I haven't tried these options before reading your comment.

Did (1), and it works when passing a number instead of the "ClientDropDown.SelectedValue".

In (2), the code fail in the line 25 of my SQLiteDataAccess Class, which is the line that use the parameters passed (@ClientId, Value) to access the DataBase. The Id is not being passed correctly from the dropdown.


10Public Class SQLiteDataAccess
11 'generic code to load data
12 'LoadData<personmodel>("Select * from Person", null) = List<personmodel>
13 Public Shared Function LoadData(Of T)(ByVal sqlStatement As String, ByVal parameters As Dictionary(Of String, Object), ByVal Optional connectionName As String = "Default") As List(Of T)
14
15 Dim p As DynamicParameters = New DynamicParameters()
16 'DynamicPirameters is a Dapper Type
17
18 For Each param In parameters
19 '@FirstName, "Tim"
20 p.Add(param.Key, param.Value)
21 Next
22
23
24 Using cnn As IDbConnection = New SQLiteConnection(DataAccessHelpers.LoadConnectionString(connectionName))
25 Dim rows = cnn.Query(Of T)(sqlStatement, p)
26 Return rows.ToList()
27 End Using
28
29 End Function
30
Member 13954123 22-Apr-19 11:22am View    
payments is declared in the beginning of the code as

Private payments As ObservableCollection(Of PaymentsModel) = New ObservableCollection(Of PaymentsModel)()