如何在VB.NET中使用Dapper更新MS Access数据库中的打印总数

问题描述 投票:0回答:1

我正在尝试使用 VB.NET 中的 Dapper 更新 MS Access 数据库表中的打印总数

每次我在按钮上执行一个事件时,我都想将数字增加 1。

我有下面的代码,但这仍然是错误的。请指导我。

谢谢

Dim pservice As New PeopleService()    
Private Sub BtnPrint_Click(sender As Object, e As EventArgs) Handles BtnPrint.Click
        Try
            Dim objprint = New People With {
               .Numberofprints = +1,
               .Transno = TextBox1.Text}
            pservice.UpdatePeoplePrint(objprint)
        Catch err As Exception
            MessageBox.Show(err.Message)
        End Try
    End Sub

Public Class People
    Public Property Transno() String
    Public Property Numberofprints() As Integer
End Class

Public Class PeopleService
    Public Sub UpdatePeoplePrint(ByVal Obj As People)
        Dim sql = $"UPDATE People Set People.Numberofprints = {Obj.Numberofprints} WHERE [People.Transno] = '{Obj.Transno}';"
        Using _conn = New OleDbConnection(GetOledbConnectionString())
            _conn.Execute(sql)
        End Using
    End Sub
End Class

桌子:

people

跨诺 打印数量
1000 1
1001
1003

所需输出

跨诺 打印数量
1000 2
1001 1
1003 1
vb.net linq ms-access dapper
1个回答
0
投票

尝试使用以下语法:

.Numberofprints += 1,

这一行可能应该是:

Public Property Transno() As String
© www.soinside.com 2019 - 2024. All rights reserved.