con.ConnectionString = ("server=127.0.0.1;user id=root;password=12345;database=dbsis3bkenth")
Try
con.Open()
With cmd
.Connection = con
.CommandText = "INSERT INTO tblreg (IDNo, LName, FName, MI, NName, Course, Yr, Div1, Gender, Age, Hght, Wght, DOB, POB, Religion, Address, Tel, AddWSudying, Scholarship, NFather, OccFather, AIncome, AgencyFather, NMother, OccMother, AgencyMother, PNEmergency, PNEAddress, Relation, PNETel, Hobbies, WEmploy, Elem, YTElem, Secondary, YTSecondary, College, YTCollege) " & _
"VALUES ('" & vcbIDNo & "','" & vtxtLName & "','" & vtxtFName & "','" & vtxtMI & "','" & vcbNName & "','" & vcbCourse & "','" & vcbYr & "','" & vcbDiv & "','" & vcbGender & "','" & vtxtAge & "','" & vtxtHght & "','" & vtxtWght & "','" & vdtpDOB & "','" & vtxtPOB & "','" & vcbReligion & "','" & vtxtAddress & "','" & vtxtTel & "','" & vtxtAddWSudying & "','" & vcbScholarship & "','" & vtxtNFather & "','" & vtxtOccFather & "','" & vtxtAIncome & "','" & vtxtAgencyFather & "','" & vtxtNMother & "','" & vtxtOccMother & "','" & vtxtAgencyMother & "','" & vtxtPNEmergency & "','" & vtxtPNEAddress & "','" & vtxtRelation & "','" & vtxtPNETel & "','" & vtxtHobbies & "','" & vtxtWEmploy & "','" & vtxtElem & "','" & vtxtYTElem & "','" & vtxtSecondary & "','" & vtxtYTSecondary & "','" & vtxtCollege & "','" & vtxtYTCollege & "');"
result = cmd.ExecuteNonQuery
For i As Integer = 0 To DataGridView1.Rows.Count - 2
.Connection = con
.CommandText = "INSERT INTO tblsisterbrother (LName, FName, MI,IDNoBrodSis) " & _
"VALUES ('" & DataGridView1.Rows(i).Cells("LN").Value.ToString & "', '" & DataGridView1.Rows(i).Cells("FN").Value.ToString & "', '" & DataGridView1.Rows(i).Cells("MI").Value.ToString & "','" & vcbIDNo & "');"
result = cmd.ExecuteNonQuery
Next
For j As Integer = 0 To DataGridView2.Rows.Count - 2
.Connection = con
.CommandText = "INSERT INTO tblorg (Organization, IDNoOrg) " & _
"VALUES ('" & DataGridView2.Rows(j).Cells("ORG").Value.ToString & "','" & vcbIDNo & "');"
result = cmd.ExecuteNonQuery
Next
If result = 0 Then
MsgBox("Data has not been Inserted!")
Else
MsgBox("Successfully saved!")
End If
End With
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()