Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
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  
Old July 7th, 2004, 09:34 AM
Kristin Kristin is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 56 Kristin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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:)

Reply With Quote
  #2  
Old July 7th, 2004, 09:42 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,738 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 1 h 41 m 10 sec
Reputation Power: 443
Saving images into a database is not recommended.
They should be saved in a folder somewhere on the server.

Reply With Quote
  #3  
Old July 7th, 2004, 10:46 AM
Kristin Kristin is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 56 Kristin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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!

Reply With Quote
  #4  
Old July 7th, 2004, 12:48 PM
GrayMagiker GrayMagiker is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 6 GrayMagiker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #5  
Old July 7th, 2004, 01:39 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,738 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 1 h 41 m 10 sec
Reputation Power: 443
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

Reply With Quote
  #6  
Old July 7th, 2004, 08:10 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 18 h 51 m 25 sec
Reputation Power: 180
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

Reply With Quote
  #7  
Old July 9th, 2004, 11:55 AM
Kristin Kristin is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 56 Kristin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
thanks...going to try that asap

Reply With Quote
  #8  
Old July 9th, 2004, 11:59 AM
Kristin Kristin is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 56 Kristin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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:
Originally Posted by GrayMagiker
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

Reply With Quote
  #9  
Old July 9th, 2004, 12:06 PM
Kristin Kristin is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 56 Kristin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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:
Originally Posted by Memnoch
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

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > saving an image file to a column in an SQL database


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM developerWorks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway