Sunday, February 19, 2012

Inserting records and displaying them

Before I start driving myself nuts, I'd like to make sure my approach is correct.

I want to create a simple job posting board.
I have a text boxes for company name, email, job title, and job description, and a submit button.
I created a table in my database called "JobPostings", with columns called "CoName", "CoEmail", "JobTitle", and "JobDesc"

When someone fills out the fields and clicks submit, it will insert the new records.

So,
1. Is this the correct approach so far?

2. What is the best way to display the job listings? A grid view?

3. At submit time, how can I include that day's date?

4. How can I get the records in the database to delete after 90 days?

Thanks.

1. If it did what you want, it's correct to youSmile

2. You can try SqlDataSource+GridView, see

3. You can add a datetime column (e.g. CreateDate) to the table, whose default value is getdate() so that when a new record being inserted you don't need to specify date for the column:

ALTER TABLE mytable ADD CreateDate DATETIME DEFAULT GetDate()

4. You can use such command to delete records older than 90 days:

DELETE FROM mytable WHERE DATEDIFF(d,CreateDate,GETDATE())>90

No comments:

Post a Comment