Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Problems updating database

Problems updating database

Scheduled Pinned Locked Moved Visual Basic
databasequestioncsssql-serversysadmin
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AAGTHosting
    wrote on last edited by
    #1

    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)

    C S 2 Replies Last reply
    0
    • A AAGTHosting

      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)

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      1 Reply Last reply
      0
      • A AAGTHosting

        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)

        S Offline
        S Offline
        SteveNY
        wrote on last edited by
        #3

        >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".

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups