phillystyle123
asked on
ASPUpload - updating existing record using form param, PT II
this question is related to this (answered yesterday):
https://www.experts-exchange.com/questions/21918804/UPDATE-EXISTING-RECORD-IN-MS-ACESS-USING-ASPUPLOAD.html
i thought i tested it but apparently something fell through the cracks!
i'm not able to update an existing record - so if i have a record who's ContentID is 65 and i try to update the filename in in the db when i do my upload to the server, taint happening- if there's no filename the filename doesn't get added to the existing record - here's my code:
<!-- AspUpload Code samples: odbc_upload.asp -->
<!-- Invoked by odbc.asp -->
<!-- Copyright (c) 2001 Persits Software, Inc. -->
<!-- http://www.persits.com -->
<HTML>
<BODY>
<%
Set Upload = Server.CreateObject("Persi ts.Upload" )
' Capture files
Upload.Save "E:\inetpub\wwwroot\smbb\n ewsite\new s\pdfs\"
' Obtain file object
Set File = Upload.Files("THEFILE")
For Each File in Upload.Files
datapath="E:\inetpub\wwwro ot\smbb\sm bb.mdb"
strConn="Provider=Microsof t.Jet.OLED B.4.0;Data Source=" & datapath
Set objConn = Server.CreateObject("ADODB .Connectio n")
objConn.Open strConn
set rs = Server.CreateObject("ADODB .RecordSet ")
Dim rsContentID__MMColParam
rsContentID__MMColParam = "ContentID"
SQL = "SELECT * FROM Content WHERE ContentID = " + Replace(rsContentID__MMCol Param, "'", "''") + ""
rs.Open SQL,objConn,1,2
if rs.eof then
rs.AddNew
end if
rs("filename") = File.ExtractFileName
rs.Update
rs.Close
set rs = nothing
objConn.Close
set objConn = nothing
Response.Write "Your PDF has been successfully uploadedd. <a href='index.asp'>Click here</a> to return to the admin."
Next
%>
</BODY>
</HTML>
Thanks!!!
https://www.experts-exchange.com/questions/21918804/UPDATE-EXISTING-RECORD-IN-MS-ACESS-USING-ASPUPLOAD.html
i thought i tested it but apparently something fell through the cracks!
i'm not able to update an existing record - so if i have a record who's ContentID is 65 and i try to update the filename in in the db when i do my upload to the server, taint happening- if there's no filename the filename doesn't get added to the existing record - here's my code:
<!-- AspUpload Code samples: odbc_upload.asp -->
<!-- Invoked by odbc.asp -->
<!-- Copyright (c) 2001 Persits Software, Inc. -->
<!-- http://www.persits.com -->
<HTML>
<BODY>
<%
Set Upload = Server.CreateObject("Persi
' Capture files
Upload.Save "E:\inetpub\wwwroot\smbb\n
' Obtain file object
Set File = Upload.Files("THEFILE")
For Each File in Upload.Files
datapath="E:\inetpub\wwwro
strConn="Provider=Microsof
Set objConn = Server.CreateObject("ADODB
objConn.Open strConn
set rs = Server.CreateObject("ADODB
Dim rsContentID__MMColParam
rsContentID__MMColParam = "ContentID"
SQL = "SELECT * FROM Content WHERE ContentID = " + Replace(rsContentID__MMCol
rs.Open SQL,objConn,1,2
if rs.eof then
rs.AddNew
end if
rs("filename") = File.ExtractFileName
rs.Update
rs.Close
set rs = nothing
objConn.Close
set objConn = nothing
Response.Write "Your PDF has been successfully uploadedd. <a href='index.asp'>Click here</a> to return to the admin."
Next
%>
</BODY>
</HTML>
Thanks!!!
ASKER
just rolled out of bed so i'm a tad less articulate than usual
records are being added to the db - i checked. i'm updating existing db records by updating the 'filename' field. basically, my client wants to upload pdfs and add links to those pdfs on the site- one per record. the pdf filenames are being added to records that have other fields, title, article, date, etc.
records are being added to the db - i checked. i'm updating existing db records by updating the 'filename' field. basically, my client wants to upload pdfs and add links to those pdfs on the site- one per record. the pdf filenames are being added to records that have other fields, title, article, date, etc.
OK, so please explain the problem again...as it relates to this code.
Also, always be sure to response.write your variables and SQL...so you know what's actually going on. Sometimes we assume the code is performing as expected, but the code is not what we expect at all.
Also, always be sure to response.write your variables and SQL...so you know what's actually going on. Sometimes we assume the code is performing as expected, but the code is not what we expect at all.
ASKER
ok -
i'm passing along the form variable "ContenID"
i need the code to do this:
update 'filename' in db where db.ContentID=formparampass ed.Content ID
i'm passing along the form variable "ContenID"
i need the code to do this:
update 'filename' in db where db.ContentID=formparampass
ASKER
ugh still struggling with this - how would i use response.write to display the form variable i'm trying to pass?
something like this?
Response.Write (rsContentID__MMColParam)
something like this?
Response.Write (rsContentID__MMColParam)
ASKER
ust did this
Response.Write rsContentID__MMColParam
and this is what i got so i'm guessing the form variable isn't being passed or it is but my code thinks the variable is "ContentID":
"Your PDF has been successfully uploadedd. Click here to return to the admin.ContentID"
Response.Write rsContentID__MMColParam
and this is what i got so i'm guessing the form variable isn't being passed or it is but my code thinks the variable is "ContentID":
"Your PDF has been successfully uploadedd. Click here to return to the admin.ContentID"
Stop using the stupid DW variables all together....they are annoying.
contentid=request("content id")
if contentid ="" then
response.write "ContentID is empty"
else
response.write "Content ID: " & contentid
end if
SQL = "SELECT * FROM Content WHERE ContentID = " & contentid
rs.Open SQL,objConn,1,2
if rs.eof then
rs.AddNew
end if
rs("filename") = File.ExtractFileName
...etc...
contentid=request("content
if contentid ="" then
response.write "ContentID is empty"
else
response.write "Content ID: " & contentid
end if
SQL = "SELECT * FROM Content WHERE ContentID = " & contentid
rs.Open SQL,objConn,1,2
if rs.eof then
rs.AddNew
end if
rs("filename") = File.ExtractFileName
...etc...
ASKER
thanks alorentz
using your code i'm getting the following error:
Request object error 'ASP 0208 : 80004005'
Cannot use generic Request collection
/newsite/admin/smbbnews/od bc_upload. asp, line 28
Cannot use the generic Request collection after calling BinaryRead.
here's your code built into the existing code:
<!-- AspUpload Code samples: odbc_upload.asp -->
<!-- Invoked by odbc.asp -->
<!-- Copyright (c) 2001 Persits Software, Inc. -->
<!-- http://www.persits.com -->
<HTML>
<BODY>
<%
Set Upload = Server.CreateObject("Persi ts.Upload" )
' Capture files
Upload.Save "E:\inetpub\wwwroot\smbb\n ewsite\new s\pdfs\"
' Obtain file object
Set File = Upload.Files("THEFILE")
For Each File in Upload.Files
datapath="E:\inetpub\wwwro ot\smbb\sm bb.mdb"
strConn="Provider=Microsof t.Jet.OLED B.4.0;Data Source=" & datapath
Set objConn = Server.CreateObject("ADODB .Connectio n")
objConn.Open strConn
set rs = Server.CreateObject("ADODB .RecordSet ")
contentid=request("content id")
if contentid ="" then
response.write "ContentID is empty"
else
response.write "Content ID: " & contentid
end if
SQL = "SELECT * FROM Content WHERE ContentID = " & contentid
rs.Open SQL,objConn,1,2
if rs.eof then
rs.AddNew
end if
rs("filename") = File.ExtractFileName
rs.Update
rs.Close
set rs = nothing
objConn.Close
set objConn = nothing
Response.Write "Your PDF has been successfully uploadedd. <a href='index.asp'>Click here</a> to return to the admin."
Response.Write ContentID
Next
%>
</BODY>
</HTML>
using your code i'm getting the following error:
Request object error 'ASP 0208 : 80004005'
Cannot use generic Request collection
/newsite/admin/smbbnews/od
Cannot use the generic Request collection after calling BinaryRead.
here's your code built into the existing code:
<!-- AspUpload Code samples: odbc_upload.asp -->
<!-- Invoked by odbc.asp -->
<!-- Copyright (c) 2001 Persits Software, Inc. -->
<!-- http://www.persits.com -->
<HTML>
<BODY>
<%
Set Upload = Server.CreateObject("Persi
' Capture files
Upload.Save "E:\inetpub\wwwroot\smbb\n
' Obtain file object
Set File = Upload.Files("THEFILE")
For Each File in Upload.Files
datapath="E:\inetpub\wwwro
strConn="Provider=Microsof
Set objConn = Server.CreateObject("ADODB
objConn.Open strConn
set rs = Server.CreateObject("ADODB
contentid=request("content
if contentid ="" then
response.write "ContentID is empty"
else
response.write "Content ID: " & contentid
end if
SQL = "SELECT * FROM Content WHERE ContentID = " & contentid
rs.Open SQL,objConn,1,2
if rs.eof then
rs.AddNew
end if
rs("filename") = File.ExtractFileName
rs.Update
rs.Close
set rs = nothing
objConn.Close
set objConn = nothing
Response.Write "Your PDF has been successfully uploadedd. <a href='index.asp'>Click here</a> to return to the admin."
Response.Write ContentID
Next
%>
</BODY>
</HTML>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can also see all that on the code sample page, that yuo've been too:
http://www.aspupload.com/codesample.html
http://www.aspupload.com/codesample.html
ASKER
thanks alorentz - all seems to be working - much appreciated
What's this mean? No filename? Why would you have that?
Also, may want to check your database to see if records are being added...because will do that is EOF.