Imports MySql.Data.MySqlClient
Public Class Form1
Dim connStr As String = "Databace=login;" & _
"Data Source=localhost;" & _
"User Id=admin;Password=123456"
Dim connention As New MySqlConnection(connStr)
Function updateRecord(ByVal query As String) As Integer
Try
Dim rowsEffected As Integer = 0
Dim connection As New MySqlConnection(ConnStr)
Dim cmd As New MySqlCommand(query, connection)
connention.Open()
rowsEffected = cmd.ExecuteNonQuery()
connention.Close()
Return rowsEffected
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Console.WriteLine(updateRecord("INSERT INTO users (username, password) VALUES ('" & txtUsername.Text & "','" & txtPassword.Text & "')"))
End Sub
End Class