I have been trying to save the data from the TextBoxes on my form to my database, and have written the below code without any errors, but the data is not saving to the database. Can anyone please help me find what I'm doing wrong
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Create variables for each selection'
Dim FirstName, LastName, DOB, FDOC, LDOC, MFirstName, MLastName, MAddress, MEmail, FFirstName, FLastName, FAddress, FEmail, MHome, MWork, MCell, FHome, FWork, FCell, ChildPhoto As String
'copy information from the textboxes to the variables'
FirstName = TextBox1.Text : LastName = TextBox2.Text : DOB = DateTimePicker1.Text : FDOC = DateTimePicker2.Text : LDOC = DateTimePicker3.Text
MFirstName = TextBox4.Text : MLastName = TextBox3.Text : MAddress = TextBox7.Text : MHome = TextBox9.Text : MWork = TextBox10.Text : MCell = TextBox13.Text : MEmail = TextBox15.Text
FFirstName = TextBox6.Text : FLastName = TextBox5.Text : FAddress = TextBox8.Text : FHome = TextBox12.Text : FWork = TextBox11.Text : FCell = TextBox14.Text : FEmail = TextBox16.Text
ChildPhoto = PictureBox1.ImageLocation
'Make sure names have been entered'
If FirstName = "" Or LastName = "" Then
MessageBox.Show( "Please enter a first and last name.")
Else
'Copy the information from the variables to the database'
Dim newChildRow As Child_Information_DatabaseDataSet.Child_InformationRow
newChildRow = Child_Information_DatabaseDataSet.Child_Information.NewChild_InformationRow
newChildRow.FirstName = FirstName : newChildRow.LastName = LastName : newChildRow.DOB = DOB : newChildRow.FDOC = FDOC : newChildRow.LDOC = LDOC
newChildRow.MFirstName = MFirstName : newChildRow.MLastName = MLastName : newChildRow.MAddress = MAddress : newChildRow.MHome = MHome : newChildRow.MWork = MWork : newChildRow.MCell = MCell : newChildRow.MEmail = MEmail
newChildRow.FFirstName = FFirstName : newChildRow.FLastName = FLastName : newChildRow.FAddress = FAddress : newChildRow.FHome = FHome : newChildRow.FWork = FWork : newChildRow.FCell = FCell : newChildRow.FEmail = FEmail
Child_Information_DatabaseDataSet.Child_Information.Rows.Add(newChildRow)
' Save the new row to the database
Me.Child_InformationTableAdapter.Update(Me.Child_Information_DatabaseDataSet.Child_Information)
'Display the MessageBox confirming the save name'
MessageBox.Show(FirstName + " " + LastName + " has been added to the child database.")
'Hide all User Controls and show Desktop'
CCPD.Main.MainUC1.Visible = True
CCPD.Main.DailyReport1.Visible = False
CCPD.Main.ChildInfoViewer1.Visible = False
CCPD.Main.AddChild1.Visible = False
End If
End Sub
Visual Studio Express Editions6
|