Dim sPhrase, sDefinition sPhrase = txtPhrase.Text sDefinition = txtDefinition.Text Dim updateCmd As String = "UPDATE dbo.Lexicon SET lex_cphrase = @lex_cphrase, lex_cdefinition = @lex_cdefinition WHERE (lex_ipk = @lex_ipk) ;" Dim myCommand As SqlCommand = New SqlCommand(updateCmd, SqlConnection1) myCommand.Parameters.Add(New SqlParameter("@lex_ipk", SqlDbType.Int)) myCommand.Parameters.Add(New SqlParameter("@lex_cphrase", SqlDbType.VarChar, 40)) myCommand.Parameters.Add(New SqlParameter("@lex_cdefinition", SqlDbType.Text)) myCommand.Parameters("@lex_ipk").Value = sipk myCommand.Parameters("@lex_cphrase").Value = sPhrase myCommand.Parameters("@lex_cdefinition").Value = sDefinition ' Connect to the database and update the information. myCommand.Connection.Open() ' Test whether the data was updated and display the ' appropriate message to the user. Try myCommand.ExecuteNonQuery() message.Text = "<b>Record Updated.</b><br>" Catch ex As SqlException If ex.Number = 2627 Then message.Text = "ERROR: A record already exists with the same primary key" Else message.Text = "ERROR: Could not update record," _ & " please ensure the fields are correctly filled out." message.Style("color") = "red" End If End Try ' Close the connection. myCommand.Connection.Close()