[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

ASP Upload (using Persits ASPUpload) error when uploading from UNC Paths.

Posted on 2004-04-01
9
Medium Priority
?
1,065 Views
Last Modified: 2007-12-19
Hello,

I am using ASP Upload to insert files into a SQL 2000 database via an ASP form.  It works fine when uploading files which are stored on the same computer which is being used to access the form, but when I try and upload files via a UNC path from a shared computer.  The error I get is below:

Error saving the file: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error


The source from the ASP page (at least the section which does the work) is as follows:

<%
Set Upload = Server.CreateObject("Persits.Upload")

if request("CN") <> "" then
     CN     = request("CN")
else
     Upload.Save "C:\temp"
     CN = Upload.form("cn")
end if
if Upload.form("upd") = "1" then
      Set File = Upload.Files("FileContent")

     if not File is nothing then
     FileType = Upload.form("FileType")
     if Upload.Form("description") = "" then description = "NULL" else description = "'"&RmAps(Upload.Form("description"))&"'"
          sqlStmt = "insert into Files (CN, Date, CreatedBy, Description, FileName, FileType, FileSize, FileContent) values "&_
                    "(" & CN & "," &_
                    " getdate(), " &_
                    "1, " &_
                    ""&description&", " &_
                    "'" & File.extractfilename & "', " &_
                    ""&FileType&", " &_
                    "" & File.Size & ", " &_
                    "?);"
         
          on error resume next
          File.ToDatabase Application("Conn"), SqlStmt
          if Err <> 0 Then
               Response.Write "<font color=RED>Error saving the file: " & Err.Description & "</font><br>"
          Else
               File.Delete
               response.write "<script>"
               response.write "window.open (""c.asp?cn="&cn&""", 'Main_App')"
               response.write "</script>"
          end if    

     else
          response.write "<font color=RED>ERROR - FILE NOT UPLOADED.</font><br><br>Please try again."
     end if          
end if
%>

Thanks for help in advance!

BTW there is another question exactly like this one from me that you can get points from if you answer this one right!
0
Comment
Question by:electricd7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 11

Expert Comment

by:Slimshaneey
ID: 10732772
Looks like a problem with the insert here:

Try this:
sqlStmt = "insert into Files (CN, Date, CreatedBy, Description, FileName, FileType, FileSize, FileContent) values "&_
                    "(" & CN & "," &_
                    " getdate(), " &_
                    "1, " &_
                    ""&description&", " &_
                    "'" & File.extractfilename & "', " &_
                    ""&FileType&", " &_
                    "" & File.Size & ", '" &_
                    "?');"
0
 
LVL 11

Expert Comment

by:Slimshaneey
ID: 10732797
I think there should also be quotes around description.... and also FileType if it is not an integer type(I ahve not put any in)::

sqlStmt = "insert into Files (CN, Date, CreatedBy, Description, FileName, FileType, FileSize, FileContent) values "&_
                    "(" & CN & "," &_
                    " getdate(), " &_
                    "1, " &_
                    "'" & description & "', " &_
                    "'" & File.extractfilename & "', " &_
                    ""&FileType&", " &_
                    "" & File.Size & ", '" &_
                    "?');"
0
 

Author Comment

by:electricd7
ID: 10732988
No the quotes are all fine.  They match the datatypes.  Sorry, forgot to mention that.  The ? at the end is specific to the "File.ToDatabase" line in my code.  Again this code works fine when not using UNC paths for the file upload.  Thanks.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 11

Expert Comment

by:mouatts
ID: 10733275
I'm wondering if sql server is misreading the \\ at the start of the UNC as something else (escaping it out for example).
Two suggestions firstly upload the same file once using a drive letter and once using UNC that will prove that it is UNC one way or another.
Secondly try replaceing \\ characters with something when you extract the filename just to establish if this is the problem.

Steve
0
 

Author Comment

by:electricd7
ID: 10733395
Actually I created a mapped drive to the UNC path thinking the exact same thing, and had the same results.  It can actually extract the filename, and I see an empty file created on the server, but for some reason the file.content is never created.

ED7
0
 
LVL 11

Expert Comment

by:mouatts
ID: 10733499
Try changing the upload.save to a upload.SaveToMemory. I'm wondering if it is try to create the file with the UNC bits in, which I guess might actually work if the UNC address is valid but you might not see it as it will overwrite the original file.

Steve
0
 

Author Comment

by:electricd7
ID: 10733766
Just changed it and it immediately did the same thing.  Its like it doesn't even begin to load the file if it is over UNC.  I know that it is supposed to support it, but i'm stumped.  Anyone have ASP Upload that can verify UNC uploading?
0
 
LVL 28

Expert Comment

by:sybe
ID: 10738670
I have written my own file-upload script (pure-asp). And i can imagine that the guys who created "Persits.Upload" forgot to check fileuploading from UNC path. The path looks different, so the filename is not being parsed correctly. I suggest you use another component.

btw - pure-script fileupload doesnot seem to be slower then component-based fileupload: http://www.taka.nl/programming/asp/comparing_fileupload.asp

http://www.aspfaq.com/show.asp?id=2189
0
 
LVL 11

Accepted Solution

by:
mouatts earned 2000 total points
ID: 10743125
Ok well I tested this on a site of mine and it worked with a UNC (I don't know why I didn't think of this sooner).
The main differences are that my code does a upload.savevirtual (I do seem to recall I had some problems with upload.save), I don't write into a database and I never do a set file I always use upload.files("filecontent"). syntax.

I'd try a savevirtual as your first step.
BTW in case you haven't checked I also looked at origainalpath and it did contain a valid UNC.

Steve
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question