I am just wondering if my code can still be simplified. I intend to make it reusable in all update statements.
Public Sub updateRecord(ByRef procedure As String, ByRef parameters As String, ByRef obj As String, ByRef LastName As String, ByRef FirstName As String, ByRef MiddleInitial As String, ByRef Age As String, ByRef Address As String) Dim CS As String = ConfigurationManager.ConnectionStrings("DBCS").ConnectionString Try Using con As New SqlConnection(CS) Dim cmd As SqlCommand = New SqlCommand(procedure, con) cmd.CommandType = System.Data.CommandType.StoredProcedure cmd.Parameters.AddWithValue(parameters, obj) cmd.Parameters.AddWithValue("@LastName", LastName) cmd.Parameters.AddWithValue("@FirstName", FirstName) cmd.Parameters.AddWithValue("@MiddleInitial", MiddleInitial) cmd.Parameters.AddWithValue("@Age", Age) cmd.Parameters.AddWithValue("@Address", Address) cmd.Connection = con con.Open() Dim TotalRows As Int32 = cmd.ExecuteNonQuery() End Using Catch ex As Exception MessageBox.Show(ex.ToString, "Annual Procurement Plan", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End Try End Sub