Ask a Question related to ASP Database, Design and Development.
-
Ralf Pelzl #1
How to write an image to db
Hello,
how do i write an image from a file source to a database on sql-server via
asp ? e.g:
I try to store file c:\temp\test.jpg in the field "picture" in a recordset.
The field "picture" is datatype image. How to do this ?
Ralf Pelzl Guest
-
how to write AS class to have image in preloader
I want to have a customised preloader, with a progressbar showing the percentage loaded and a predefined logo( .gif / .jpeg )in the initialization... -
write to database without giving write permission to IIS
Hi there, I have some ASP code that writes to access database. For security reason I do not want IUSER to give write permission to database... -
JPG stored as long binary in database: how to write output as image in asp?
Hello, For a while I am working with ThumbsPlus ( http://www.cerious.com/ ) as manager for pics. The benefit of the program is that it stores... -
How To Browse for an image file and save it to image server folder
I trying to browse for an image file and save it to the server image folder. in other words , upload the picture. I tried html and aspx.net... -
Can I take a small (320x240), blurry image, and make it a clear, large image?
Just wondering if there is an easy way to do this? I'm sure it won't be perfect cause photoshop can only work with what's there, but maybe it can... -
Manohar Kamath [MVP] #2
Re: How to write an image to db
Here's something I wrote to do just that, all you need to do is fill in some
gaps:
<%
Function GuestConnString()
GuestConnString = "provider=sqloledb;data
provider=sqloledb;server=xxxx;data source=xxxx;User
ID=xxxx;password=xxx;Initial Catalog=xxxx;"
End Function
Function getHexStream(docPath)
Dim loStream
Set loStream = Server.CreateObject("ADODB.Stream")
loStream.Open
loStream.Type = 1 'adTypeBinary
loStream.loadFromFile(docPath)
' Create an XML DOM document
Set loXMLDoc = Server.CreateObject("MSXML2.DomDocument")
loXMLDoc.async = False
' Create the node to hold file data
Set loFile = loXMLDoc.CreateNode("element", "filedata", "")
loFile.dataType = "bin.hex"
loFile.nodeTypedValue = loStream.Read
' Get the HEX representation of the file
getHexStream = "0x" & loFile.Text
Set loStream = Nothing
Set loFile = Nothing
Set loXMLDoc = Nothing
End Function
Function InsertDocument(docPath)
Dim loConn, lsSQL, lsFileExt, lsFileName
Set loConn = Server.CreateObject("adodb.connection")
loConn.Open GuestConnString
lsFileName = Split(StrReverse(docPath), "\")(0)
lsFileExt = StrReverse(Split(lsFileName, ".")(0))
lsSQL = "sp_insertDocument '" & lsFileExt & "', " & getHexStream(docPath)
On Error Resume Next
loConn.Execute(lsSQL)
loConn.Close
Set loConn = Nothing
InsertDocument = Err.Number
End Function
Dim lsFilePath
lsFilePath = "c:\myfolder\mypic.jpg"
If Not IsEmpty(lsFilePath) Then
If InsertDocument(lsFilePath) = 0 Then
Response.Write("File processed succesfully!")
Else
Response.Write("Failure during file procesing.")
End If
End If
%>
--
Manohar Kamath
Editor, .netBooks
[url]www.dotnetbooks.com[/url]
"Ralf Pelzl" <ralf.pelzl@inf.hs-anhalt.de> wrote in message
news:OPINs%23mVDHA.2340@TK2MSFTNGP10.phx.gbl...recordset.> Hello,
> how do i write an image from a file source to a database on sql-server via
> asp ? e.g:
> I try to store file c:\temp\test.jpg in the field "picture" in a> The field "picture" is datatype image. How to do this ?
>
>
>
>
Manohar Kamath [MVP] Guest



Reply With Quote

