|
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.
|