Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post

    Question Insert Binary into DB?

    How do I send a binary picture into a database If I already have the binary that needs to be inserted?

    File.Binary = The picture I have, already in binary form.


    Why do I get the error "Type mismatch" when I try:

    oConn = Connectiong to DB

    Strimage = File.Binary

    sSQL = "INSERT INTO images (image) VALUES (" & Strimage & ")"

    Set oRS = oConn.Execute(sSQL)

    ...?

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've never inserted binary data into a db... but have you tried it as a string (just guessing here)?

    sSQL = "INSERT INTO images (image) VALUES ('" & Strimage & "')"
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #3
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Just a shot in the dark:

    Code:
    http://www.google.com/search?hl=en&q=%22SQL%22+Inserting+binary+picture+via+ASP+NOT+VB6
    Look here.

    I personally haven't done it otherwise I'd be more helpful.
    Last edited by oracleguy; 07-07-2002 at 07:31 AM.
    OracleGuy

  • #4
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    Whammy, that doesn't matter, I don't think. It doesn't change anything though... Maybe you could acually explan to me the differance in the two ways? '" & str & "' over " & Str & " for inserting into a database even with normal strings...



    Oracleguy, first off...

    http://www.google.com/search?hl=en&l...=Google+Search

    ...is the link your's got cut because of some script this forum has. It turns some of the text into "...". Also I would rather use a forum then do a search because the result in a search might not beable to get the type of code I am looking for with what specifications i am looking for, plus i already looked, and found nothing. (I would rather use a forum )


    I think I can do anyother way, but I don't know exactly how to do it. I am taking this from an old uploader that doesn't use a component.

    Code:
    	Dim RS,Con,Cstring,sql,MYMESSAGE,i,j
    			CString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/db/images.mdb")
                Set CON = server.CreateObject("adodb.connection")
    			Con.open Cstring
    			Set RS = Server.CreateObject("ADODB.Recordset")
    			SQL= "SELECT filename, filesize, contenttype, filedata, fullname, EMAIL, story, t from my"
    			RS.Open SQL,con,2,3
    			RS.AddNew
    			RS("filename")    = File.FileName
    			RS("filesize")	  = File.FileSize
    			RS("contenttype") = Request.servervariables("remote_addr")
    		    RS("FULLNAME")    = Uploader.Form("fullname")
    			RS("EMAIL")    = Uploader.Form("EMAIL")
    			RS("story")    = Uploader.Form("story")
    			RS("t")    = DATE
    			' Save the file to the database
    			File.SaveToDatabase RS("filedata")
    			' Commit the changes and close
    			RS.Update
    			RS.Close
    I am gunna mess around with that now. If you can help, see what you can do too.

    Thank you, Whammy, Oracleguy.

  • #5
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    I don't get it!!!!
    I went into the options for the databse folder and set Web Sharing to share this folder, at the begining. nothing happend.
    I turned it off just now, and I went to security and added in "Everyone" and it worked... maybe with the old code, but I used the new code.

    Code:
    Dim  oConn, strconn, RS, sSQL
    Set oConn = server.CreateObject("ADODB.Connection")
    strconn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("db/images.mdb") & ";"
    oConn.open strconn
    Set RS = Server.CreateObject("ADODB.Recordset")
    sSQL = "SELECT image FROM images"
    RS.Open sSQL,strconn,2,3
    RS.AddNew
    RS("image") = File.Binary
    RS.Update
    RS.Close


  •  

    Posting Permissions

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