ho do i store information to a mysql database? what i am trying to do is to fill out some students information and when i try to click save it should be saved to a mysql database.... here is my code but every time i click save it couldn't connect to the database.... whats wrong with my code? thanks guys
Imports MySql.Data.MySqlClient
Public Class Form1
Dim str As String
Dim conn As MySqlConnection
Dim cmd As MySqlCommand
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
str = " host = localhost ; username = 'root'; password = 'root'; database= asiawise; pooling = false;"
conn = New MySqlConnection(str)
conn.Open()
cmd.CommandText = "INSERT INTO students(last_name,date_enrolled ,first_name ,category ,age ,level,mentor,schedule) VALUES('textbox1.text','textbox3.text','textbox2.text','ComboBox1.text','textbox4.text','ComboBox2.text','textbox5.text','ComboBox3.text');"
cmd.Connection = conn
cmd.ExecuteNonQuery()
conn.Close()
Catch ex As Exception
MessageBox.Show("Connection has timedout.")
End Try
End Sub
End Class