Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-01-10 : 00:01:40
|
Adrian writes "I have a UserFiles table and a Files table. The Files table contains all the files that have been registered with the database. eg. FileID,FileName,FileDetails. The UserFiles table contains all files that each users has. eg. FileID,UserID. When a user logs in they tell the database what files they have. At the moment my adding routine is very slow and I see another way of doing it. I add a record to the UserFiles table and then look up it that file has been registered in the Files table. If it has not the add it to the Files table. i then assign the ID of the Record in the Files table to the new UserFiles Record.
Here is a piece of dummy code to show how I am doing it.
for each item in UserFilesArray _UserFilesRec.addnew _UserFileRec("UserID")=UserID _FileRec=dbc.execute("SELECT * FROM Files WHERE FileName='"&FileName&"'") _if FileRec.eof then __FileRec.addnew __FileRec("FileName")=FileName __FileRec("FileDetails")=FileDetails __FileRec.update _end if _UserFilesRec("FileID")=FileRec("FileID") _UserFiles.update _FileRec.close next
I know there must be a better way to do this but I cant seem to figure it out. I know opening database connections in a loop is a stupid thing to do and every time a user logs in and submits files my database chokes. Any help would be greatly appreciated." |
|
|
|
|
|