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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. delete records automatically from database

delete records automatically from database

Scheduled Pinned Locked Moved ASP.NET
csharphelptutorialasp-netdatabase
8 Posts 5 Posters 1 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.
  • P Offline
    P Offline
    Pratheepa
    wrote on last edited by
    #1

    Hi, I am using asp.net C# and ms Access as database . my website is abt displaying advertisements posted by users who re registered. All work well but my problem is how to delete posted advertisements after a perticular days. for example if user request to display the advertisemnt for one month then the advertosemnt shud get deleted automatically from the database after the time finishes. Is there a way to do this task? Plz help me

    M N S 3 Replies Last reply
    0
    • P Pratheepa

      Hi, I am using asp.net C# and ms Access as database . my website is abt displaying advertisements posted by users who re registered. All work well but my problem is how to delete posted advertisements after a perticular days. for example if user request to display the advertisemnt for one month then the advertosemnt shud get deleted automatically from the database after the time finishes. Is there a way to do this task? Plz help me

      M Offline
      M Offline
      Manas Bhardwaj
      wrote on last edited by
      #2

      Ignore repost

      Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

      1 Reply Last reply
      0
      • P Pratheepa

        Hi, I am using asp.net C# and ms Access as database . my website is abt displaying advertisements posted by users who re registered. All work well but my problem is how to delete posted advertisements after a perticular days. for example if user request to display the advertisemnt for one month then the advertosemnt shud get deleted automatically from the database after the time finishes. Is there a way to do this task? Plz help me

        N Offline
        N Offline
        Niladri_Biswas
        wrote on last edited by
        #3

        Hi man, since it is MS Access so you cannot use trigger; For this situations the best solution is to write a trigger. Alternatively, write a program in c#, that will do the necessary task. Write the program in the Form Load event so that the checking will happen every time when the application will run. Also create a table in MS Access with three fields say AdvertisementId , StartDate, EndDate. So what will happen is that, everytime the form will load,the StartDate will be checked with end date corresponding to the Advertisement Id. If the StartDate < EndDate, just update the StartDate by 1(i.e. 1 day will be incremented). When StartDate = EndDate, execute the delete operation. But always do it in the Form Load event Hope this helps :)

        Niladri Biswas

        1 Reply Last reply
        0
        • P Pratheepa

          Hi, I am using asp.net C# and ms Access as database . my website is abt displaying advertisements posted by users who re registered. All work well but my problem is how to delete posted advertisements after a perticular days. for example if user request to display the advertisemnt for one month then the advertosemnt shud get deleted automatically from the database after the time finishes. Is there a way to do this task? Plz help me

          S Offline
          S Offline
          saanj
          wrote on last edited by
          #4

          I will recommend you to maintain a validTillDate flag in the respective table column for various advertisements. In the page when you are going to show the advertisement, just check whether the validDate flag is greater than the current date or not. If it is then simply don't show the advertisement. Deleting data from the table is not recomended from the future perspective. Hope this helps. Regards Saanj

          There is no foolish question, there is no final answer...

          N P 2 Replies Last reply
          0
          • S saanj

            I will recommend you to maintain a validTillDate flag in the respective table column for various advertisements. In the page when you are going to show the advertisement, just check whether the validDate flag is greater than the current date or not. If it is then simply don't show the advertisement. Deleting data from the table is not recomended from the future perspective. Hope this helps. Regards Saanj

            There is no foolish question, there is no final answer...

            N Offline
            N Offline
            N a v a n e e t h
            wrote on last edited by
            #5

            saanj wrote:

            I will recommend you to maintain a validTillDate flag in the respective table column for various advertisements. In the page when you are going to show the advertisement, just check whether the validDate flag is greater than the current date or not. If it is then simply don't show the advertisement.

            +5 :)

            Navaneeth How to use google | Ask smart questions

            S 1 Reply Last reply
            0
            • S saanj

              I will recommend you to maintain a validTillDate flag in the respective table column for various advertisements. In the page when you are going to show the advertisement, just check whether the validDate flag is greater than the current date or not. If it is then simply don't show the advertisement. Deleting data from the table is not recomended from the future perspective. Hope this helps. Regards Saanj

              There is no foolish question, there is no final answer...

              P Offline
              P Offline
              Pratheepa
              wrote on last edited by
              #6

              cud u plz explain in detail? i wud be thankful if u cud send me any link(url) where i can get more idea.

              S 1 Reply Last reply
              0
              • N N a v a n e e t h

                saanj wrote:

                I will recommend you to maintain a validTillDate flag in the respective table column for various advertisements. In the page when you are going to show the advertisement, just check whether the validDate flag is greater than the current date or not. If it is then simply don't show the advertisement.

                +5 :)

                Navaneeth How to use google | Ask smart questions

                S Offline
                S Offline
                saanj
                wrote on last edited by
                #7

                Thanks Navneet. :-\ Regards Saanj

                There is no foolish question, there is no final answer...

                1 Reply Last reply
                0
                • P Pratheepa

                  cud u plz explain in detail? i wud be thankful if u cud send me any link(url) where i can get more idea.

                  S Offline
                  S Offline
                  saanj
                  wrote on last edited by
                  #8

                  You may have a table called "tblAdvertisement" where you are storing all advertisements. This is the table from which you are also showing advertisments in the page. Now add a seperate column (of datetime type) called "validTillDate" column. Whenever you are inserting any record in the "tblAdvertisement", put a "validTillDate" for the advertisement. "validTillDate" simply stores the date till the advertisement will be valid and active. When you are going to show advertisments on the page, check all advertisements' "validTillDate" column pick only those advertisement whose "validTillDate" column value is less than or equal to the current date. It will be best if you can check it in the sql statement itself. Just checkout the sample sql query:

                  select * from tblAdvertisement where validTillDate <= getdate()

                  I think this explanation should be enough for you to get started. There is no link and url that I can give to you as there is more logic invloved than coding. In case of any issue, revert back to us. Regards Saanj

                  There is no foolish question, there is no final answer...

                  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