If credits.Text <= 0 Then MsgBox("Geen credits meer.") Else Dim conn As MySqlConnection conn = New MySqlConnection conn.ConnectionString = "server=xxx;port=3306; user id=xxx; password=xxx; database=xxx" Try conn.Open() Catch myerror As MySqlException MsgBox("error connecting to database") End Try Dim myadapter As New MySqlDataAdapter Dim sqlquery = "UPDATE account SET credits = credits -700 WHERE id='" & Trim(id.Text) & "'" Dim mycommand As New MySqlCommand() mycommand.Connection = conn mycommand.CommandText = sqlquery myadapter.SelectCommand = mycommand mycommand.ExecuteNonQuery() Try conn.Close() Catch myerror As MySqlException MessageBox.Show("Cannot connect to database: " & myerror.Message) Finally conn.Dispose() End Try End If
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)