By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,162 Members | 1,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,162 IT Pros & Developers. It's quick & easy.

Insert Image as BLOb

P: 8
Do you know how to insert an image with blob field in asp? I have a code but I have an error, can you help me?
Apr 18 '17 #1
Share this Question
Share on Google+
9 Replies


ADezii
Expert 5K+
P: 8,652
I've attached a Demo that I created awhile ago that demonstrates how to Edit a specific Graphic Image stored as A BLOB in an OLE Object Field. The original Code is from Alan Warren which I modified to suit a specific User's needs. It also clearly illustrates multiple aspects of BLOB Storage, including: writing a Graphic File as a BLOB to an OLE Object Field, how to read an Image stored as a BLOB, how to Edit a BLOB Image, etc. Most of the relevant Code is contained within the Code Module behind frmInventory.

P.S. - You can also reference this Article that I wrote awhile ago. It generated a lot of interest with multiple Replies from very knowledgeable individuals. You should find it very interesting.
http://bytes.com/topic/access/insigh...blob-not-movie
Attached Files
File Type: zip Blobs_2.zip (887.6 KB, 80 views)
Apr 18 '17 #2

P: 8
ADezii Will it serve me in sql?
Apr 18 '17 #3

P: 8
I have this code is asp and it gives me error in the log file
Apr 18 '17 #4

P: 8
Expand|Select|Wrap|Line Numbers
  1. f Request.TotalBytes > 0 Then
  2. req_bytes = Request.BinaryRead(tot_bytes)
  3.  'Parse POSTed request JSON
  4.  'Parse POSTed request JSON
  5.  reqArgsString = BytesToStr(req_bytes)
  6.  reqArgsArray = Split(reqArgsString, "&")
  7.  For i = 0 To UBound(reqArgsArray)
  8.     reqArgsArray(i) = Split(reqArgsArray(i), "=")
  9.  Next
  10.  
  11.  'Decode base64 image from JSON POST to BytesArray'
  12.  'Decodificar la imagen base64 de JSON POST a Bytes Array'
  13.  base64Encoded = URLDecode(reqArgsArray(1)(1))
  14.  base64Decoded = decodeBase64(base64Encoded)
  15.  'Response.Write base64Decoded
  16.  '' GoTo Done
  17.  
  18.  
  19.   'DB Connection Object
  20.  'Set cn = Server.CreateObject("ADODB.Connection")
  21.  'ConnStr="DRIVER=SQL Server;SERVER=161.196.101.140;UID=sa;PWD=P@ssw0rdsql;Database=ContinuumDB"
  22.  'cn.Open ConnStr
  23.  'Dim strQry 
  24.  'strQry = "INSERT INTO GA_BLOB (""Blob_Segment"", ""Blob_Person_ID"") VALUES (?, ?)"
  25.  
  26.  ' strQry = "INSERT INTO GA_BLOB (""Blob_Person_ID"", ""Blob_Image_ID"", ""Blob_Segment_No"", ""Blob_Format"", ""Blob_Segment"") VALUES (?, ?)"'
  27.  
  28.  '"insert into GA_BLOB (Blob_Person_ID, Blob_Image_ID, Blob_Segment_No, Blob_Format, Blob_Segment) values ('" & Request.form("Blob_Person_ID") & "', '" 0 "','" 0 "','" 0 "', '" & Request.form("Blob_Segment") & "')"'
  29.  
  30.  'Dim cm As ADODB.Command
  31.  'Set cm = New ADODB.Command
  32.  'cm.ActiveConnection = cn
  33.  'cm.CommandText = strQry
  34.  'cm.Parameters.Append cm.CreateParameter("@Blob_Segment", adVarBinary, adParamInput, 100, base64Decoded) 'Leave this parameter first
  35.  'cm.Parameters.Append cm.CreateParameter("@Blob_Person_ID", adInteger, adParamInput, , reqArgsArray(1)(1))
  36.  'cm.CommandType = adCmdText
  37.  'cm.Execute
Apr 18 '17 #5

NeoPa
Expert Mod 15k+
P: 31,533
I've split this hijack question into a new thread in the ASP forum as that's explained as the language used.

@Douglas.
Please be more careful when posting your questions and never add one to an existing thread. Always use the [CODE] tags when including code.

@ADezii.
When you see a hijack of an old thread it's far better to report it than to respond to it. In this case I suspect the question is not only a hijack but also posted in a thread from entirely the wrong forum.

Alternatively feel free to PM me if you see any issue.
Apr 19 '17 #6

ADezii
Expert 5K+
P: 8,652
When you see a hijack of an old thread it's far better to report it than to respond to it. In this case I suspect the question is not only a hijack but also posted in a thread from entirely the wrong forum.
My apologies, missed both points (ASP + Hijack)! Wrongly focused in on the BLOB.
Apr 19 '17 #7

NeoPa
Expert Mod 15k+
P: 31,533
Don't worry about it :-) I doubt Douglas realised what he was doing either. It's not always easy to start in a new environment and get things right first time.

These are just pointers to help.
Apr 19 '17 #8

P: 8
A thousand apologies just comment seeing the possibility that some of you have the knowledge of what happens to me and could help me really apologize if I offended them I only look for a help to see if they know something of the code in which I am working.
Apr 20 '17 #9

NeoPa
Expert Mod 15k+
P: 31,533
We understand Douglas. We assumed you were innocently asking for help. Sometimes it's difficult to notice some of the other details when you're focused on your own problems.

BTW The thread's been moved to the ASP area now for you. Hopefully you'll get some interest, but often experts will see a thread which already has answers and move on. Also, the Access area is certainly the busiest on the site so I'm not sure how busy this one is nowadays. Even though I'm an administrator of the site as a whole my work is mainly in Access, which I know keeps quite busy.

Best of luck.
Apr 20 '17 #10

Post your reply

Sign in to post your reply or Sign up for a free account.