Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 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
CodePudding user response:
You create the command but you never execute it . You need to open the connection and call ExecuteNonQuery on the command.
CodePudding user response:
in your try catch block
Try
cmd.ExecuteNonQuery()
cmd.Dispose()
myconnection.Close()
ProductIDTextBox.Clear()
ProductNameTextBox.Clear()
QuantityTextBox.Clear()
PriceTextBox.Clear()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Please add something like MessageBox to show the error