Hello,
I am using MySQL database connected to Visual Studio 2017 Community Edition. I have a checkbox and textboxes on a Winform VB.Net. In my MySQL database, the datatype of the Status checkbox is ENUM('T','F'). I have some vb.net code to update changes in the form.
The vb.net code is:
Code:
Private Sub UpdateStatus(Optional messages As Boolean = True)
Dim query = "UPDATE Plans Set Status = @status, PlanNotes = @plannotes " &
"WHERE PLANID = @planId"
con = New MySqlConnection("Server=localhost;Port=3306;Database=mydatabase;userid=root;password=mypassword;persist security info=True")
con.Open()
cmd = New MySqlCommand(query, con)
cmd.Parameters.AddWithValue("@status", Me.ChkStatus.Checked)
cmd.Parameters.AddWithValue("@plannotes", Me.txtPlanNotes.Text)
cmd.Parameters.AddWithValue("@planId", Me.txtPlanID.Text)
cmd.ExecuteNonQuery()
con.Close()
End Sub
If I try to input any changes in the data fields and press the Update button, an error message is thrown at the line: cmd.ExecuteNonQuery() as follows: -
Code:
MySql.Data.MySqlClient.MySqlException: 'Data truncated for column 'Status' at row 1'