All I am trying to do is update my access but I got alot of erros. I have Stor_ID in a combobox and it loads the info. Now I am trying to update the information. All I want to do is update city and state.
VB.NET:
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
UpdateStoreID()
Dim strcmd As String = "UPDATE Stores SET"
strcmd &= "City = @city, "
strcmd &= "State = @state, "
Dim cmdUpdate As New OleDbCommand(strcmd, conDB)
With cmdUpdate
cmdUpdate.Parameters.Add("@city", txtCity.Text)
cmdUpdate.Parameters.Add("@state", txtState.Text)
End With
Try
conDB.Open()
cmdUpdate.ExecuteNonQuery()
'MessageBox.Show("Update confirmed!")
Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
conDB.Close()
End Try
End Sub
Private Sub UpdateStoreID()
Dim cmdGetStoreInt As New OleDbCommand("Select Stor_ID from Stores where stor_ID = @ID", conDB)
cmdGetStoreInt.Parameters.Add("@Stor_ID", cboStoreID.SelectedItem)
Try
If conDB.State = ConnectionState.Closed Then
conDB.Open()
End If
intStoreID = cmdGetStoreInt.ExecuteScalar
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
conDB.Close()
End Try
End Sub
Last edited by a moderator: