|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Blob I I
FIRSTLY:
Mods... this may be better placed in the ASP Section, but to avoid duplicating it I will leave it here. SECONDLY: Call me cynical, but, I don't really expect anybody to answer my question, it would be nice just ocasionally! No offence intended to those who have so kindly helped me out... both times. THIRDLY: The question: I have an ASP Page, and a neat tool from StrongCube to upload blobs (files to you and me). I would like to insert said blob into a table in my sql 2000 database. My prefered method is through a stored procedure due to the nature of the system, and its security setting, stored procedures offer the most flexible arrangements. So, what are the design implications of creating such a stored procedure, and what are the design implications of writing such an ASP script. Thanks in advance... The usual rules apply regarding reputation points: no win no fee. |
|
#2
|
||||
|
||||
|
What exactly are the blobs you are uploading? Images?
|
|
#3
|
||||
|
||||
|
Non-specific - the data type is IMAGE (not to be confused with pictures), however the blob could be anything jpg, word file, code samples (even though thats text, the file headers must be retained)
|
|
#4
|
||||
|
||||
|
Quote:
Your question itself is kind of vague. What concerns do you have about doing this? |
|
#5
|
||||
|
||||
|
My main problem is this:
How do you pass a blob to a stored procedure with an asp script? Can you just dump it into a SQL Server variable of type image? A snippet of code may be able to shed some light.. Thanks again alex |
|
#6
|
||||
|
||||
|
There are numerous examples of storing BLOBS in SQL Server on google.
Yes, I would use the Image data type. The Image data type just stores binary information. |
|
#7
|
||||
|
||||
|
Quote:
Thanks for that useful comment... Here is one such example: http://www.stardeveloper.com/articl...d.html?tid=1010 |
|
#8
|
||||
|
||||
|
OK, so after much soul searching, and many a sware break, I have the following ASP code:
these are lines 42 through to 53(highlighted) Code:
cmdObj.CommandType = 4
cmdObj.commandText = "exec sp_uploadNewFile"
cmdobj.parameters.append cmdObj.createParameter("folderID", 3, 1, len(varFolderID), varFolderID)
cmdObj.Parameters.Append cmdobj.createParameter("personID", 3, 1, len(varPersonID), varPersonID)
cmdObj.Parameters.Append cmdobj.createParameter("projectID", 3, 1, len(varProjectID), varProjectID)
cmdObj.Parameters.Append cmdObj.createParameter("fileName", 12, 1, len(varFileName), varFileName)
cmdObj.Parameters.Append cmdobj.createParameter("description", 200, 1, len(varFileDesc), varFileDesc)
cmdObj.Parameters.Append cmdobj.createParameter("@contentType", 200, 1, len(varContentType), varContentType)
cmdObj.Parameters.Append cmdobj.createParameter("@theFile", 204, 1, varFileSize)
cmdObj.Parameters("theFile").AppendChunk varTheFile
cmdObj.Execute
and the stored procedure I had written earlier Code:
ALTER procedure sp_uploadNewFile ( @folderID numeric, @personID numeric, @projectID numeric, @fileName nvarchar(255), @theFile image, @description nvarchar(255)=null, @contentType nvarchar(255)) as insert into [file] values(@folderid, @personID, @projectID, @fileName, 0.00, 0, @theFile, @description, @contentType) and finally the error: error '80040e14' /vm/modules/genUpload.asp, line 53 OK so two questons: 1) what would cause this error? I have checked the opperation of the stored procedure in Query analyzer, and have checked that the variables (varPersonID etc...) have values execpt varFileDesc because this is an optional field. 2) how can I see what the query string that is being executed looks like? |
|
#9
|
||||
|
||||
|
WOOT! I've fixed the problem...
After many more sware breaks, fully aimed at microsoft for such a clumsy interface. I did the following to remadiate the issue: update my Microsoft Data Access Components from what ever version I had to v2.8. This then gave me some error messages at least. rather than just an error code. The other issue that I discovered, is that using the append parameter method, is that ADO doen't care about what you name your SQL parameters, you have to supply the parameters in the order that you have placed them in the stored procedure. I was trying to put them create the parameters in a manner to that looked nice and logical from a coding point of view, and ADO didn't like it. Any how all sorted now... The code above is correct an should work, and can be adapted how you wish. MODS: can I have reputation for my self please! ![]() |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Blob I I |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|