為什么 Integer ID 無法在帶有訪問資料庫的 vb.net 中使用 dapper 正確加載到 datagridview 中。是否有其他解決方案或應該編碼功能,以便 ID 出現在 datagridview 中。我的代碼中的 datagridview 使用 nuget 包“Kimtoo.Bindingprovider”,我還使用帶有 Access 資料庫的 nuget 包 dapper。
Public Class TEST
Public Property Id() As Integer
Public Property Itemproduct() As String
Public Property Quantity() As Integer
End Class
Public Class Form1
Private record As TEST
Public Function GetConnectionString() As String
Dim strCon As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|"
strCon &= "\DB_TEST.accdb;Persist Security Info=False;"
Return strCon
End Function
Public Con As New OleDbConnection(GetConnectionString())
Private Sub LoadData()
Try
Dim data As List(Of TEST) = Con.Query(Of TEST)("Select * From TEST").ToList()
'DataGridView1.Bind(data)
DataGridView1.DataSource = data
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
LoadData()
End Sub

uj5u.com熱心網友回復:
Access 資料庫中的列名稱為ID(大寫)。在課堂TEST上,Id改為ID
Public Class TEST
Public Property ID As Integer
Public Property Itemproduct As String
Public Property Quantity As Integer
End Class
其他資源
- 自動實作的屬性 (Visual Basic)
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/529157.html
上一篇:當資訊通常存盤在2個單獨的行中時,如何在SQL中添加第二個價格列
下一篇:VBNET長字串中的SQL引數
