Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · Web Hosting Plans · Faisal Khan's Blog · Contact
Forums : ASP : ADO/ODBC : Making file upload unrequired Signup · Login
Author Thread
Making file upload unrequired
Posted in tutorial: Uploading Files into an Access Database using plain ASP
·  JasonFen
User
Joined: 5 Apr 2005
Total Posts: 3
Making file upload unrequired
Posted: 5 Apr 2005
Currently, it acts like the rest of the data submits, but unless a file is actually uploaded, nothing gets input into the db. I see someone else figured this out, but didn't give the solution.
·  pkerr
User
Joined: 7 Oct 2005
Total Posts: 2
One Solution that I've Found
Posted: 7 Oct 2005
I had the same problem. I had other fields that might need to be inserted into the database but not necessarily a document.

I used a stored procedure as shown in http://www.stardeveloper.com/articles/thread.html?tid=1010

When it came to adding the parameter for the document I used a logic test to decide if to upload document or upload NULL value. Here's my ASP code (modified to protect the undeserving)

Dim cmdInsertData
Set cmdInsertData= Server.CreateObject("ADODB.Command")

With cmdInsertData
.ActiveConnection = Conn
.CommandType = adCmdStoredProc
.CommandText = "{call _mysp_insertData(?,?,?,?)}"
.Parameters.Append cmdInsertData.CreateParameter("person_id", 3, 4,4)
.Parameters.Append cmdInsertData.CreateParameter("lastname", 200,1, 50,lnameInput)
.Parameters.Append cmdInsertData.CreateParameter("firstName", 200,1, 50,fnameInput)
End With

If Len(documentName) > 0 Then
cmdInsertData.Parameters.Append cmdInsertData.CreateParameter("document", 205,1,documentSize)
cmdInsertData.Parameters("document").Attributes = adFldLong
cmdInsertData.Parameters("document").AppendChunk documentData
Else
cmdInsertData.Parameters.Append cmdInsertData.CreateParameter("document", 205,1,1)
cmdInsertData.Parameters("document").Attributes = adFldLong
cmdInsertData.Parameters("document").AppendChunk NULL
End If
cmdInsertData.Execute
PersonId = cmdInsertData.Parameters("person_id").Value

I tried many different configurations around the code but this is the only one that worked.

Now, I'm just a baby programmer and I encourage others to provide better code.

Users Who Have Visited This Thread In Last 24 Hours
5 Visitors

Login
UserName Or Email Address:       Password:       Auto-Login:    
· Create New User Account
· Send Forgotten Password by Email
 
© 1999 - 2009 Stardeveloper.com, All Rights Reserved.