crazy_beautiful
Member
- Joined
- Jan 27, 2005
- Messages
- 9
- Programming Experience
- 1-3
hi would you guys help me? i made a code so that whenever i filled up all the required fields in my form a message box will tell that it has added the record. i think my code here is right but when i already filled all the information up, it displays my error handler message that
"You have missed a field. Please Go back". Although i have filled all the required field, it still comes up with the error handler. how will i possible add the record here? what's wrong with my code? what code will i replace or add if i must do so? please help..
"You have missed a field. Please Go back". Although i have filled all the required field, it still comes up with the error handler. how will i possible add the record here? what's wrong with my code? what code will i replace or add if i must do so? please help..
VB.NET:
[size=2]
[/size][size=2][color=#0000ff]Public[/color][/size][size=2][color=#0000ff]Sub[/color][/size][size=2] AddRecord()
[/size][size=2][color=#0000ff]Try
[/color][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] daSoloParent [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]New[/color][/size][size=2] OleDbDataAdapter(cmmInsert)
[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] dsSoloParent [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]New[/color][/size][size=2] DataSet
[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] m_baptized [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]String
[/color][/size][size=2][color=#0000ff]If[/color][/size][size=2] chkBaptized.Checked = [/size][size=2][color=#0000ff]True[/color][/size][size=2][color=#0000ff]Then
[/color][/size][size=2]m_baptized = "Yes"
[/size][size=2][color=#0000ff]Else
[/color][/size][size=2]m_baptized = "No"
[/size][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]If
[/color][/size][size=2]cmmInsert.Connection = conConnection
[/size][size=2][color=#008000]'OPEN CONNECTION
[/color][/size][size=2]conConnection.Open()
[/size][size=2][color=#008000]'ADD THE SOLO PARENT
[/color][/size][size=2]cmmInsert.CommandText = "INSERT INTO SoloParent (LastName,FirstName,MiddleName) VALUES ('" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtLastName.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtFirstName.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtMiddleName.Text & "')"
daSoloParent.Fill(dsSoloParent)
[/size][size=2][color=#008000]
[/color][/size][size=2][color=#008000]
[/color][/size][size=2][color=#008000]'CLOSE CONNECTION
[/color][/size][size=2]conConnection.Close()
[/size][size=2][color=#008000]'OPEN CONNECTION
[/color][/size][size=2]conConnection.Open()
[/size][size=2][color=#008000]'ADD THE SOLO PARENT
[/color][/size][size=2]cmmInsert.CommandText = "INSERT INTO SoloParentInformation (HomeAddress,OfficeName,OfficeAddress,LandlineNumber,MobileNumber,BirthDate,PlaceOfBirth,Baptized,Age,Gender) VALUES ('" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtHomeAddress.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtOfficeName.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtOfficeAddress.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtSoloParentLandLineNumber.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtSoloParentMobileNumber.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtBirthDate.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtPlaceOfBirth.Text & "','" & m_baptized & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtSoloParentAge.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtSoloParentGender.Text & "')"
daSoloParent.Fill(dsSoloParent)
[/size][size=2][color=#008000]'CLOSE CONNECTION
[/color][/size][size=2]conConnection.Close()
[/size][size=2][color=#008000]'OPEN CONNECTION
[/color][/size][size=2]conConnection.Open()
[/size][size=2][color=#008000]'ADD THE CHILDREN
[/color][/size][size=2]cmmInsert.CommandText = "INSERT INTO SoloParentChildren (LastName,FirstName,MiddleName,Age,Gender) VALUES ('" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildLastName1.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildFirstName1.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildMiddleName1.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildAge1.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].cboChildGender1.Text & "')"
daSoloParent.Fill(dsSoloParent)
[/size][size=2][color=#008000]'CLOSE CONNECTION
[/color][/size][size=2]conConnection.Close()
[/size][size=2][color=#008000]'ADD CHILDREN MORETHAN 1
[/color][/size][size=2][color=#0000ff]If[/color][/size][size=2] txtChildName2.Text <> " " [/size][size=2][color=#0000ff]Then
[/color][/size][size=2][color=#008000]
[/color][/size][size=2][color=#008000]'OPEN CONNECTION
[/color][/size][size=2]conConnection.Open()
[/size][size=2][color=#008000]'ADD THE CHILDREN
[/color][/size][size=2]cmmInsert.CommandText = "INSERT INTO SoloParentChildren (LastName,FirstName,MiddleName,Age,Gender) VALUES ('" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildLastName2.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildFirstName2.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildMiddleName2.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildAge2.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].cboChildGender2.Text & "')"
daSoloParent.Fill(dsSoloParent)
[/size][size=2][color=#008000]'CLOSE CONNECTION
[/color][/size][size=2]conConnection.Close()
[/size][size=2][color=#0000ff]ElseIf[/color][/size][size=2] txtChildName3.Text <> " " [/size][size=2][color=#0000ff]Then
[/color][/size][size=2][color=#008000]'OPEN CONNECTION
[/color][/size][size=2]conConnection.Open()
[/size][size=2][color=#008000]'ADD THE CHILDREN
[/color][/size][size=2]cmmInsert.CommandText = "INSERT INTO SoloParentChildren (LastName,FirstName,MiddleName,Age,Gender) VALUES ('" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildLastName2.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildFirstName2.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildMiddleName2.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildAge2.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].cboChildGender2.Text & "')"
daSoloParent.Fill(dsSoloParent)
[/size][size=2][color=#008000]'CLOSE CONNECTION
[/color][/size][size=2]conConnection.Close()
[/size][size=2][color=#008000]'OPEN CONNECTION
[/color][/size][size=2]conConnection.Open()
[/size][size=2][color=#008000]'ADD THE CHILDREN
[/color][/size][size=2]cmmInsert.CommandText = "INSERT INTO SoloParentChildren (LastName,FirstName,MiddleName,Age,Gender) VALUES ('" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildLastName3.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildFirstName3.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildMiddleName3.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildAge3.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].cboChildGender3.Text & "')"
daSoloParent.Fill(dsSoloParent)
[/size][size=2][color=#008000]'CLOSE CONNECTION
[/color][/size][size=2]conConnection.Close()
[/size][size=2][color=#0000ff]ElseIf[/color][/size][size=2] txtChildName4.Text <> " " [/size][size=2][color=#0000ff]Then
[/color][/size][size=2][color=#008000]'OPEN CONNECTION
[/color][/size][size=2]conConnection.Open()
[/size][size=2][color=#008000]'ADD THE CHILDREN
[/color][/size][size=2]cmmInsert.CommandText = "INSERT INTO SoloParentChildren (LastName,FirstName,MiddleName,Age,Gender) VALUES ('" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildLastName2.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildFirstName2.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildMiddleName2.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildAge2.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].cboChildGender2.Text & "')"
daSoloParent.Fill(dsSoloParent)
[/size][size=2][color=#008000]'CLOSE CONNECTION
[/color][/size][size=2]conConnection.Close()
[/size][size=2][color=#008000]'OPEN CONNECTION
[/color][/size][size=2]conConnection.Open()
[/size][size=2][color=#008000]'ADD THE CHILDREN
[/color][/size][size=2]cmmInsert.CommandText = "INSERT INTO SoloParentChildren (LastName,FirstName,MiddleName,Age,Gender) VALUES ('" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildLastName3.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildFirstName3.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildMiddleName3.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildAge3.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].cboChildGender3.Text & "')"
daSoloParent.Fill(dsSoloParent)
[/size][size=2][color=#008000]'CLOSE CONNECTION
[/color][/size][size=2]conConnection.Close()
[/size][size=2][color=#008000]'OPEN CONNECTION
[/color][/size][size=2]conConnection.Open()
[/size][size=2][color=#008000]'ADD THE CHILDREN
[/color][/size][size=2]cmmInsert.CommandText = "INSERT INTO SoloParentChildren (LastName,FirstName,MiddleName,Age,Gender) VALUES ('" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildLastName4.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildFirstName4.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildMiddleName4.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtChildAge4.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].cboChildGender4.Text & "')"
daSoloParent.Fill(dsSoloParent)
[/size][size=2][color=#008000]'CLOSE CONNECTION
[/color][/size][size=2]conConnection.Close()
[/size][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]If
[/color][/size][size=2][color=#008000]'ADD MODE OF PAYMENT, AMOUNT, ORNumber, and PRNumber[/color][/size]
[size=2][color=#008000]'IF THE RADIO BUTTON IS CHECKED
[/color][/size][size=2][color=#0000ff]If[/color][/size][size=2] rbtnCash.Checked = [/size][size=2][color=#0000ff]True[/color][/size][size=2][color=#0000ff]Then
[/color][/size][size=2][color=#008000]'OPEN CONNECTION
[/color][/size][size=2]conConnection.Open()
[/size][size=2][color=#008000]'ADD THE CHILDREN
[/color][/size][size=2]cmmInsert.CommandText = "INSERT INTO Payment (ModeOfPayment,ORNumber,PRNumber,Amount) VALUES ('" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtCash.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtORNo.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtPRNo.Text & "','" & m_Amount & "')"
daSoloParent.Fill(dsSoloParent)
[/size][size=2][color=#008000]'CLOSE CONNECTION
[/color][/size][size=2]conConnection.Close()
[/size][size=2][color=#0000ff]Else
[/color][/size][size=2][color=#008000]'OPEN CONNECTION
[/color][/size][size=2]conConnection.Open()
[/size][size=2][color=#008000]'ADD THE CHILDREN
[/color][/size][size=2]cmmInsert.CommandText = "INSERT INTO Payment (ModeOfPayment,ORNumber,PRNumber,Amount) VALUES ('" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtCheck.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtORNo.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtPRNo.Text & "','" & m_Amount & "')"
daSoloParent.Fill(dsSoloParent)
[/size][size=2][color=#008000]'CLOSE CONNECTION
[/color][/size][size=2]conConnection.Close()
[/size][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]If
[/color][/size][size=2][color=#008000]'ADD SPONSOR
[/color][/size][size=2][color=#008000]'OPEN CONNECTION
[/color][/size][size=2]conConnection.Open()
[/size][size=2][color=#008000]'ADD THE CHILDREN
[/color][/size][size=2]cmmInsert.CommandText = "INSERT INTO Sponsor (LastName,FirstName,MiddleName,Address,LandlineNumber,MobileNumber) VALUES ('" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtSponsorLastName.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtSponsorFirstName.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtSponsorMiddleName.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtSponsorAddress.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtSponsorLandlineNumber.Text & "','" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtSponsorMobileNumber.Text & "')"
daSoloParent.Fill(dsSoloParent)
[/size][size=2][color=#008000]'CLOSE CONNECTION
[/color][/size][size=2]conConnection.Close()
[/size][size=2]
[/size][size=2][color=#008000]'ADD RESERVATION
[/color][/size][size=2][color=#008000]'OPEN CONNECTION
[/color][/size][size=2]conConnection.Open()
[/size][size=2]cmmInsert.CommandText = "INSERT INTO Reservation (ReservationDate) VALUES ('" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtReservationDate.Text & "')"
daSoloParent.Fill(dsSoloParent)
[/size][size=2][color=#008000]'CLOSE CONNECTION
[/color][/size][size=2]conConnection.Close()
MsgBox("You have added a record", MsgBoxStyle.Information, "")
[/size][size=2][color=#0000ff]Catch[/color][/size][size=2] ex3 [/size][size=2][color=#0000ff]As[/color][/size][size=2] Exception
[/size][size=2]MsgBox("You have missed a field. Please Go back", MsgBoxStyle.Critical + MsgBoxStyle.Information, "Error")
[/size][size=2][color=#008000]
[/color][/size][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]Try
[/color][/size][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]Sub
[/color][/size]
Last edited: