|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
saving an image file to a column in an SQL database
OK, anyone know why this isn't working? I make the following declarations in the General section:
Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Dim mstream As ADODB.Stream then I placed a command button on the form with the following code... Private Sub Command1_Click() Set cn = New ADODB.Connection cn.Open "Provider=SQLOLEDB;data Source=MRO;Initial Catalog=MRO;User Id=sa;Password=xxx" Set rs = New ADODB.Recordset rs.Open "Select * from records", cn, adOpenKeyset, adLockOptimistic Set mstream = New ADODB.Stream mstream.Type = adTypeBinary mstream.Open mstream.LoadFromFile "\\Mro\mro\TEST\test2.tif" rs.Fields("labreport").Value = mstream.Read rs.Update rs.Close cn.Close End Sub I found this as an example on a Microsofts support site because I need to store Image files as part of a record in a database. But, I get a compile error on "Dim mstream As ADODB.Stream" and it says user-defined type not defined! Anyone out there know where I went wrong???? Kristin ![]() Last edited by Kristin : July 7th, 2004 at 09:36 AM. Reason: oops:) I put my connection information in there:) |
|
#2
|
||||
|
||||
|
Saving images into a database is not recommended.
They should be saved in a folder somewhere on the server. |
|
#3
|
|||
|
|||
|
hmm, ok, have any ideas for me for a "workaround"??? I'm Federally regulated, and have to link these images to the records somehow.
help! |
|
#4
|
|||
|
|||
|
Hmmm....
Sounds like you are missing something in the project references. Since you got it to compile the first two declarations, I assume you have "Microsoft ActiveX Data Objects 2.0 Library" Checked. I did some experimenting and got it to work using "Microsoft ActiveX Data Objects 2.7 Library" Instead Check under Project>References and see if you have that If you do not then you might try installing the latest MDAC Service pack, or contacting Microsoft about the missing file The service pack can be obtained here http://www.microsoft.com/downloads/...&DisplayLang=en or by linking to it from MS KB article 300635 If you do not like following a long and potentially dangerous url like that |
|
#5
|
||||
|
||||
|
Just store the path to the image in the database, then just reference it in you code, using the <img src> tag, like this
Code:
Do until rs.eof
Response.write("<img src='" & rs("ImagePath") & "'>")
rs.movenext
loop
|
|
#6
|
|||
|
|||
|
Did you add a reference in your project to the Microsoft Data Access Components?
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#7
|
|||
|
|||
|
thanks...going to try that asap
|
|
#8
|
|||
|
|||
|
I tried this, however, when I switch to the 2.7, I get compile errors when I try to run the application because (I am assuming) it was created with the 2.0??????
what do you think? Quote:
|
|
#9
|
|||
|
|||
|
can you elaborate?
We are on a local network here, how can I save the files (coming in off a fax server) to another location on the server - and then access it easily? And I need to write a sort of "if record exists where specimenid="666" then labreport = "imagePath" else new record"
make sense? I need it to find a location to belong to or just begin a new record. And how do I get it to pull and store the image source easily if it is on the server? I have to create a user interface for girls here in the office to use this and have to make it simple..... I am doing everything through forms.... what do you think? Kristin ![]() Quote:
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > saving an image file to a column in an SQL database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
![]() |
|