I am using the code below to allow me to upload 4 images simultaneously, and also write member information to a database. Problem is, the member information is added for each image that is uploaded. Each member will have 4 images, and I do not need the info to be entered 4 times. Is there a way I can have this information only enter once for each group of 4 member images uploaded?
Just query the database before you insert the data and check to see if the companyName and/or other information still exists. If it exists then don't insert it again. Simple.
There are more logical ways to do it, but I think that would be the easiest with your current code.
Example:
PHP Code:
'imageRS.Open "images", strConnect, adOpenStatic, adLockOptimistic, adCmdTable
imageRs.Open "SELECT * FROM [images] WHERE [companyName]='"&companyName&"' AND [address]='"&address&"'", strConnect, adOpenStatic, adLockOptimistic
if imageRS.EOF then '//If the current companyName/address combination does not exixt then add it.
imageRS.AddNew
imageRS("companyName") = companyName
imageRS("address") = address
imageRS("addressFr") = addressFr
imageRS("telephone") = telephone
imageRS("fax") = fax
imageRS("tollfree") = tollfree
imageRS("desc") = desc
imageRS("descFr") = descFr
imageRS("imagePath") = imagePath
imageRS("imagePathSmall") = imagePathSmall
imageRS.Update
end if
imageRS.Close
Set imageRS = Nothing
The LOGICAL way to do this is to apply some "database normalisation" and split your company information and image information into TWO separate tables.
So, company information table would be:
ID - Autonumber
CompanyName
address
addressFr
telephone
fax
tollfree
desc
descFr
And your image information table would be:
ID - Autonumber
CompanyID
ImagePath
ImagePathSmall
You then insert the company information ONCE into the company information table, after the RS.Update you retrieve the autonumber ID (CompanyID = RS("ID") and then use that ID when you insert the four images into the image information table to create a relationship.
Bookmarks