delete records automatically from database
-
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
-
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
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.
-
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
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
-
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
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...
-
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...
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
-
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...
-
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
-
cud u plz explain in detail? i wud be thankful if u cud send me any link(url) where i can get more idea.
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...