Binary and Image data transfer to sql 7

Results 1 to 3 of 3

Thread: Binary and Image data transfer to sql 7

  1. #1
    Nathan Reiter Guest

    Default Binary and Image data transfer to sql 7

    I am developing an app in which a image file must be uploaded<BR> onto a sql server 7.0 database. I have two pages conducting <BR>the operation. One page is an html submission form that than<BR>goes to a .asp page using ado to connect the the sql server database.<BR> <BR><BR>The first html page code is shown below:<BR> <BR>&#060;Html&#062;<BR>&#060;Head&#062;<BR>&#060; Title&#062; File Input Testing &#060;/Title&#062;<BR>&#060;/Head&#062;<BR>&#060;body&#062;<BR> &#060;FORM name="FileTest" method = "Post" enctype= "multipart/form-data"<BR> action="http://trd_webdev/LocDriLic/VbsInc/ProcessNewImage.asp"&#062;<BR> &#060;Input Type ="file" id = "image" name="image"&#062;&#060;/input&#062;<BR> &#060;Input Type = "Submit"&#062;&#060;/input&#062;<BR> &#060;/FORM&#062;<BR>&#060;/body&#062;<BR>&#060;/Html&#062;<BR><BR><BR>This first page accesses the .asp page. The asp page processes the binary data. However, the midb() vbscript command returns a string variant to the imagedata variable below (The Midb() being needed to seperate the header and body fields of the HTML source.). Thus when the sql image field is assigned the imagedata variable, a invalid data error occurs. A cbyte() function on the imagedata variable, frustratingly, gives a invalid operation error.<BR><BR><BR> Here is the .asp code below<BR><BR><BR>&#060;%<BR> <BR> <BR> dim rawdata<BR> dim imagedata<BR> dim pos<BR> dim numChars<BR> dim lRec <BR> <BR> numChars = Request.TotalBytes<BR> <BR> rawdata = Request.BinaryRead(numChars)<BR> <BR> <BR> pos = InstrB(rawdata, (ChrB(13) + ChrB(10)) + (ChrB(13) + ChrB(10)))<BR> <BR> <BR> &#039 Code not working here, the MidB function <BR> &#039 returns a string = causing the field to choke<BR> &#039 on the img assignment?<BR> <BR> <BR> if pos &#062; 0 then <BR> <BR> imagedata = MidB(rawdata, pos + 4)<BR> <BR> &#039 vartype test of image data here string<BR> &#039Response.Write(vartype(imagedata))<BR> <BR><BR> <BR> <BR> else<BR> <BR> imagedata = rawdata<BR> <BR> end if<BR> <BR> set lRec = server.CreateObject("ADODB.Recordset")<BR> <BR> lRec.Open "Select * From license" , _<BR> Application.Contents("SQLCN"), adOpenKeyset, adLockOptimistic<BR> <BR> lRec.AddNew<BR> <BR> &#039 bombs here <BR> <BR> lRec.Fields("img")= imagedata<BR> <BR> lRec.Update<BR> <BR> lRec.Close<BR> <BR> set lRec = nothing <BR> <BR> Response.Redirect("../DataSummary.asp")<BR> <BR>%&#062;<BR><BR> I have done a cbyte() function on the imagedata variable, and get a typemismatch error. Does anyone that has worked on imageinary data types and variables have suggestions out there.<BR><BR> Any input would be greatly appreciated. Thanks<BR>

  2. #2
    webgengiskhan Guest

    Default RE: Binary and Image data transfer to sql 7

    you may use an activex named aspupload.... its very easy with...<BR>go to

  3. #3
    Nathan Reiter Guest

    Default RE: Binary and Image data transfer to sql 7

    Thanks for the url , the component seems to work great. Nathan<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts