Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Put html file in database field

Status
Not open for further replies.

discusmania

IS-IT--Management
Oct 24, 2000
158
AP
Hello guys!!!

1.I"m planning to let my web page viewer to create html files and the files will be stored as a database object, and the field will be called files. what data type should i use to store the file?

2. Then after let say 10 records/files stored in the database the 10th records will be automatically deleted. How to do this... Please help me.

Thank you very much


 
1. If you are using Access, you will probably need the field to be of type Memo - text limited to 255 characters.

If you are using SQL Server 7 - I am doing the same sort of thing for a site - I would make the field of type varchar, and set the max length to 8000 (the maximum for varchar data type). Any more than that and you have to use type text - but then it gets messy when you try and read / write.

2. Do a "SELECT Count(*) FROM table_name". If this returns more than ten records then do a "DELETE * FROM table_name WHERE ID NOT IN (SELECT TOP 10 ID FROM table_name ORDER BY DateAdded DESC)"

This assumes that you have an ID field against each record and that there is a field called DateAdded which holds the date and time that the records were added to the table. (default value of "Now()" in Access or "(getdate())" in SQL Server 7.

Simon
 
Also remember to replace all single quotes found in the text to double single quotes so that you may insert them via SQL successfully.



Wushutwist


Sun Certified Java 2 Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top