【问题标题】:Ms access not updating through VB.NetMs 访问未通过 VB.Net 更新
【发布时间】:2022-11-17 17:02:10
【问题描述】:

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 处理 Button5.Click

    pro = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + "D:\FINAL PROJECT VB INVENTORY MANAGEMENT\Inventory.accdb;"
    connstring = pro
    myconnection.ConnectionString = connstring
    myconnection.Open()

    command = "Update stock set ProductName='" & ProductNameTextBox.Text & "', Quantity='" & QuantityTextBox.Text & "' , Price='" & PriceTextBox.Text & " where ProductID=" & ProductIDTextBox.Text & ""
    Dim cmd As OleDbCommand = New OleDbCommand(command, myconnection)

    MessageBox.Show("Data Updated!")
    Try
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        myconnection.Close()
        ProductIDTextBox.Clear()
        ProductNameTextBox.Clear()
        QuantityTextBox.Clear()
        PriceTextBox.Clear()

    Catch ex As Exception

    End Try
End Sub

【问题讨论】:

    标签: vb.net visual-studio ms-access


    【解决方案1】:

    您创建了命令,但您从未执行过它。您需要打开连接并在命令上调用 ExecuteNonQuery。

    【讨论】:

    • 尝试这样做,仍然没有更新我的 MS 访问
    猜你喜欢
    • 1970-01-01
    • 2011-02-15
    • 2017-03-20
    • 1970-01-01
    • 2018-09-23
    • 1970-01-01
    • 1970-01-01
    • 2011-05-04
    • 1970-01-01
    相关资源
    最近更新 更多