why datagridview in form2 doesn't appear population with dapper MS-Acess in VB.NET?
if I change the datasource datagridview to the GetItem()
function then the population appears in the datagridview. Is there something wrong with my code? . Please Guide
Thanks
'iN Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Form2.Show()
End Sub
'in FORM2
Private iService As New Itemservice2()
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
DataGridView1.DataSource = iService.Getitem2(Form1.Btxtcodeproduct.Text)
End Sub
End Class
Public Function Getitem() As IEnumerable(Of Stocks)
Dim sql = "SELECT * FROM Stocks"
Using _conn = New OleDbConnection(DbContext.GetOledbConnectionString())
Return _conn.Query(Of Stocks)(sql).ToList()
End Using
End Function
Public Function Getitem2(ByVal code As String) As Stocks
Dim sql = $"SELECT * FROM Stocks WHERE CodeProduct = '{code}'"
Using _conn = New OleDbConnection(DbContext.GetOledbConnectionString())
Return _conn.Query(Of Stocks)(sql).FirstOrDefault()
End Using
End Function
Public Class Stocks
Public Property Id() As Integer
Public Property CodeProduct() As String
Public Property Colorcode() As String
Public Property Size() As String
Public Property Qty() As Integer
End Class
result datagridview in form2 with function getitem()
in accordance with the guidelines of @dr.null then I got the perfect answer
Public Function Getitem2(ByVal code As String) As IEnumerable(Of Stocks)
Dim sql = $"SELECT * FROM Stocks WHERE CodeProduct = '{code}'"
Using _conn = New OleDbConnection(DbContext.GetOledbConnectionString())
Return _conn.Query(Of Stocks)(sql).ToList()
End Using
End Function