Adding data in multiple tables in vb.net
- by user225269
This is a winform and I'm using mysql as a database, here is my code:
I'm trying to add data into multiple tables.
If TextBox14.Text = "" Or TextBox7.Text = "" Or TextBox10.Text = "" Then
MsgBox("Please fill up the fields with a labels in bold letters!", MsgBoxStyle.Information)
cn = New MySqlConnection("Server=localhost; Database=school;Uid=root;Pwd=nitoryolai123$%^;")
'provider to be used when working with access database
cn.Open()
cmd = New MySqlCommand("select * from parents, mother, father", cn)
cmd.CommandText = "insert into parents values('" + idnum + "','" + p_contact + "','" + p_ad + "')"
cmd.CommandText = "insert into mother values('" + idnum + "','" + mother + "','" + mother_occu + "')"
cmd.CommandText = "insert into father values('" + idnum + "','" + father + "',''" + father_occu + "')"
cmd.ExecuteNonQuery()
I get this error, please help:
Index and length must refer to a location within the string. Parameter name: length