Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use <code>MySQLCommand</code> instead of <code>MySQLDataAdapter</code>. You are defeating the purpose of using ADONet because still your code is vulnerable with sql injection. Make it parameterized. Below is a modified code from your code. It uses <code>Using-End Using</code> for proper handling of object disposal. </p> <pre><code>Dim ConnectionString As String ="Server=" &amp; FormLogin.ComboBoxServerIP.SelectedItem &amp; ";Port=3306;Uid=trojan;Password=horse;Database=accounting" Dim iQuery As String = "UPDATE customer " &amp; _ "SET accountNumber = @accountNumber, nameLAST = @nameLAST, nameFIRST = @nameFIRST, " &amp; _ " nameSALUTATION = @nameSALUTATION, nameCOMPANY = @nameCOMPANY, addressSTREET = @addressSTREET, " &amp; _ " addressSTREET1 = @addressSTREET1, addressCITY = @addressCITY, addressSTATE = @addressSTATE, " &amp; _ " addressZIPCODE = @addressZIPCODE, phone = @phone, fax = @fax, email = @email " &amp; _ "WHERE accountNumber = @accountNumber" Using dbConn As New MySqlConnection(ConnectionString) Using dbComm As New MySQLCommand() With dbComm .Connection = dbConn .CommandType = CommandType.Text .CommandText = iQuery .Parameters.AddWithValue("@accountNumber", TextBoxAccount.Text ) .Parameters.AddWithValue("@nameLAST", TextBoxLastName.Text) .Parameters.AddWithValue("@nameFIRST", TextBoxFirstName.Text) .Parameters.AddWithValue("@nameSALUTATION", ComboBoxSalutation.SelectedItem) .Parameters.AddWithValue("@nameCOMPANY", TextBoxCompanyName.Text) .Parameters.AddWithValue("@addressSTREET", TextBoxAddress1.Text) .Parameters.AddWithValue("@addressSTREET1", TextBoxAddress2.Text) .Parameters.AddWithValue("@addressCITY", TextBoxCity.Text) .Parameters.AddWithValue("@addressSTATE", ComboBoxState.SelectedItem) .Parameters.AddWithValue("@addressZIPCODE", MaskedTextBoxZip.Text) .Parameters.AddWithValue("@phone", MaskedTextBoxPhone.Text) .Parameters.AddWithValue("@fax", MaskedTextBoxFax.Text) .Parameters.AddWithValue("@email", TextBoxEmail.Text) End With Try dbConn.Open dbComm.ExecuteNonQuery() MessageBox.Show("Customer account SUCCESSFULLY updated!") Call lockForm() Catch( ex as MySQLException) MessageBox.Show("A DATABASE ERROR HAS OCCURED" &amp; vbCrLf &amp; vbCrLf &amp; ex.Message &amp; vbCrLf &amp; _ vbCrLf + "Please report this to the IT/Systems Helpdesk at Ext 131.") Finally dbConn.Close() End Try End Using End Using </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload