Hi All,
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
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
VB.NET:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Try
str = "Database=pcs;" & _
"Data Source=127.0.0.1;" & _
"User Id=root;Password=awardsw;" & _
"Connection Timeout=20"
conn.ConnectionString = str
conn.Open()
cmd.CommandText = "INSERT INTO computers(computernumber,computertype,Factory,serialnumber,PartNumber,RAM,HardDisk,HDDSN,CDDVD,CDDVDSN,VGACARD,VGARAM,KeyboardType,MouseType,MonitorType,MoreInfo,Repairinfo) VALUES('ComputernumberTextBox.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