Database table backup Question

Last post 09-15-2006 11:54 AM by DE_Kabal. 4 replies.

Sort Posts:

  • Database table backup Question

    09-14-2006, 3:36 PM
    • Member
      190 point Member
    • DE_Kabal
    • Member since 08-29-2006, 2:17 PM
    • Posts 45

    I can create the backup of a table but I would like to update the backup every quarter. Is there an example of how to do that somewhere? I am using MS-Access and ASP.Net 2. Here is the code I use to make the initial backup. When I click the button is says table already exists.

    Protected Sub btnArchive_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnArchive.Click

      Dim strConn As String = ConfigurationManager.ConnectionStrings("accmon").ConnectionString
      Dim mySQL As String = "Select agency, url, datescan INTO history FROM websites"
      Dim MyConn As New OleDbConnection(strConn)
      MyConn.Open()
      Dim cmd1 As New OleDbCommand(mySQL, MyConn)
      cmd1.ExecuteNonQuery()
      MyConn.Close()
      MultiView1.SetActiveView(archiveResult)
    End Sub

  • Re: Database table backup Question

    09-14-2006, 3:49 PM
    • Participant
      1,005 point Participant
    • ThE_lOtUs
    • Member since 09-22-2005, 8:40 PM
    • Posts 201

    You should be using a INSERT statment, I'm not sure about the syntax but it look like this: INSERT INTO table1 (fields) SELECT fields FROM table2

     If it's a backup table, why not just copy the .mdb file ? If your database gets corrupt both table will be corrupt.

    Puzzles, brain teases, riddles, enigmas: http://www.toysforthebrain.com
  • Re: Database table backup Question

    09-14-2006, 10:21 PM
    Answer
    • Star
      12,930 point Star
    • Iori_Jay
    • Member since 04-04-2006, 10:21 AM
    • Posts 2,450

    SELECT...INTO... command will create a new table to host the result set returned in the SELECT list. If you want to append recoreds to the backup table, you can use the INSERT INTO...SELECT command as ThE_IOtUs said; if you want to update the backup table to the last version, you need to delete the previous rows and then insert new rows, as UPDATE ...SET...FROM...WHERE command seems to be not supported in Access.

    Welcome to my SQL/ASPNET forum for Chinese
    http://51up.org/bbs/forumdisplay.php?fid=38
  • Re: Database table backup Question

    09-15-2006, 11:33 AM
    • Member
      190 point Member
    • DE_Kabal
    • Member since 08-29-2006, 2:17 PM
    • Posts 45

    I'm really archiving the quarterly reports for one table and not the whole database. I will try what you suggested above.

    thanks;

  • Re: Database table backup Question

    09-15-2006, 11:54 AM
    Answer
    • Member
      190 point Member
    • DE_Kabal
    • Member since 08-29-2006, 2:17 PM
    • Posts 45

    Thanks again and its work great. If you don't mind if I wanted to update two fields, in all the records, in the table, how do I create a routine that does that? Any help would be great.

    thanks;

     

Page 1 of 1 (5 items)