Problems updating database
-
I am writing a software program. When I tried to add a student and then check the student drop down box the student added successfuly, but when I try to add a lesson the lesson does not add. I added a message box to see if the info was adding to the dataRow for the database Update and the info showed up in the messageBox. When I check the lesson listView the lesson is not there. How do I find out if the lesson is adding to the database? I am using SQL Server Express 2005 and the Copy to output directory is set to copy always. Here is my code.
Public addRow As DataRow
MsgBox(txtInstrument.Text & "," & Convert.ToInt32(cboSelectStudent.SelectedValue) & "," & Convert.ToDateTime(dtpStartDate.Text) & "," & Convert.ToDateTime(dtpEndDate.Text) & "," & Convert.ToDateTime(lvwItem.SubItems(1).Text) & "," & intDay & "," & Convert.ToInt32(cboSelectTeacher.SelectedValue) & "," & intLessStat)
addRow = lpDataSet.tbl\_lessons.Newtbl\_lessonsRow() addRow("less\_instrument") = txtInstrument.Text addRow("stud\_id") = Convert.ToInt32(cboSelectStudent.SelectedValue) If dtpStartDate.Visible = True Then addRow("less\_start\_date") = Convert.ToDateTime(dtpStartDate.Text) End If If dtpEndDate.Visible = True Then addRow("less\_end\_date") = Convert.ToDateTime(dtpEndDate.Text) End If If lvwChooseTimeslot.Visible = True Then addRow("less\_time") = Convert.ToDateTime(lvwItem.SubItems(1).Text) addRow("less\_day") = intDay addRow("teach\_id") = Convert.ToInt32(cboSelectTeacher.SelectedValue) End If addRow("less\_status") = intLessStat lpDataSet.tbl\_lessons.Rows.Add(addRow)
lessonTableAdapter.Update(addRow)
-
I am writing a software program. When I tried to add a student and then check the student drop down box the student added successfuly, but when I try to add a lesson the lesson does not add. I added a message box to see if the info was adding to the dataRow for the database Update and the info showed up in the messageBox. When I check the lesson listView the lesson is not there. How do I find out if the lesson is adding to the database? I am using SQL Server Express 2005 and the Copy to output directory is set to copy always. Here is my code.
Public addRow As DataRow
MsgBox(txtInstrument.Text & "," & Convert.ToInt32(cboSelectStudent.SelectedValue) & "," & Convert.ToDateTime(dtpStartDate.Text) & "," & Convert.ToDateTime(dtpEndDate.Text) & "," & Convert.ToDateTime(lvwItem.SubItems(1).Text) & "," & intDay & "," & Convert.ToInt32(cboSelectTeacher.SelectedValue) & "," & intLessStat)
addRow = lpDataSet.tbl\_lessons.Newtbl\_lessonsRow() addRow("less\_instrument") = txtInstrument.Text addRow("stud\_id") = Convert.ToInt32(cboSelectStudent.SelectedValue) If dtpStartDate.Visible = True Then addRow("less\_start\_date") = Convert.ToDateTime(dtpStartDate.Text) End If If dtpEndDate.Visible = True Then addRow("less\_end\_date") = Convert.ToDateTime(dtpEndDate.Text) End If If lvwChooseTimeslot.Visible = True Then addRow("less\_time") = Convert.ToDateTime(lvwItem.SubItems(1).Text) addRow("less\_day") = intDay addRow("teach\_id") = Convert.ToInt32(cboSelectTeacher.SelectedValue) End If addRow("less\_status") = intLessStat lpDataSet.tbl\_lessons.Rows.Add(addRow)
lessonTableAdapter.Update(addRow)
You select from the database again and see if your record is there. I would write actual database code to do the update, then I wouldn't have any questions that it worked.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
I am writing a software program. When I tried to add a student and then check the student drop down box the student added successfuly, but when I try to add a lesson the lesson does not add. I added a message box to see if the info was adding to the dataRow for the database Update and the info showed up in the messageBox. When I check the lesson listView the lesson is not there. How do I find out if the lesson is adding to the database? I am using SQL Server Express 2005 and the Copy to output directory is set to copy always. Here is my code.
Public addRow As DataRow
MsgBox(txtInstrument.Text & "," & Convert.ToInt32(cboSelectStudent.SelectedValue) & "," & Convert.ToDateTime(dtpStartDate.Text) & "," & Convert.ToDateTime(dtpEndDate.Text) & "," & Convert.ToDateTime(lvwItem.SubItems(1).Text) & "," & intDay & "," & Convert.ToInt32(cboSelectTeacher.SelectedValue) & "," & intLessStat)
addRow = lpDataSet.tbl\_lessons.Newtbl\_lessonsRow() addRow("less\_instrument") = txtInstrument.Text addRow("stud\_id") = Convert.ToInt32(cboSelectStudent.SelectedValue) If dtpStartDate.Visible = True Then addRow("less\_start\_date") = Convert.ToDateTime(dtpStartDate.Text) End If If dtpEndDate.Visible = True Then addRow("less\_end\_date") = Convert.ToDateTime(dtpEndDate.Text) End If If lvwChooseTimeslot.Visible = True Then addRow("less\_time") = Convert.ToDateTime(lvwItem.SubItems(1).Text) addRow("less\_day") = intDay addRow("teach\_id") = Convert.ToInt32(cboSelectTeacher.SelectedValue) End If addRow("less\_status") = intLessStat lpDataSet.tbl\_lessons.Rows.Add(addRow)
lessonTableAdapter.Update(addRow)
>When I check the lesson listView the lesson is not there. Is the listview control bound? If it's not then it won't automatically pick up the changes in the db. >How do I find out if the lesson is adding to the database? One way is in VS, in your Data Sources window, right click the table name and click "Preview Data".