Solved

RUSH >>> Loading picture

Posted on 2004-09-24
8
202 Views
Last Modified: 2010-05-02
why does the picture doesnt load, pls debug my code, what is stored in tblAdv_FileName field in my database is just a link to the picture (like c:/proj1/images/pic1.jpg). this code of mine is stored in the Form_Load() event.

Dim conn As New ADODB.Connection
Set conn = New ADODB.Connection
Dim rs As New ADODB.Recordset
Set rs = New ADODB.Recordset

conn.CursorLocation = adUseClient
conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _
& "DATABASE=BHMTC;" _
& "UID=root;" _
& "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384

conn.Open

rs.Open "SELECT * FROM tblAdv", conn, adOpenStatic, adLockOptimistic

Picture1.Picture = LoadPicture(rs.Fields(tblAdv_FileName))

rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
0
Comment
Question by:justin_316_sr
  • 4
  • 2
  • 2
8 Comments
 
LVL 8

Expert Comment

by:mladenovicz
ID: 12141448
add this line

Debug.Print rs.Fields(tblAdv_FileName)

to see what value did you get from DB
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 12141458
Offtopic, this

Dim conn As New ADODB.Connection
Set conn = New ADODB.Connection
Dim rs As New ADODB.Recordset
Set rs = New ADODB.Recordset

change to

Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset

Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 12141467
Also, you should use Set when loading picture

Set Picture1.Picture = LoadPicture(rs.Fields(tblAdv_FileName).Value)

0
 
LVL 10

Assisted Solution

by:anv
anv earned 20 total points
ID: 12141490
Before u execute the statement

Picture1.Picture = LoadPicture(rs.Fields(tblAdv_FileName))

make sure the File stored in the Field name "tblAdv_FileName" exists on the hard drive

U Need to check the whole path of the file or image u want to load..

if u r storing the whole path of the file in ur database then only it will display image..else not..

in ur othet question, i feel u r only storing the file name and not the filepath..

try to store the file name using commondialog1.FileName

0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:justin_316_sr
ID: 12141518
@mladenovicz
there's an error, (item cannot be found in the collection corresponding to the requested name or ordinal) on the debug line you suggested, i added it before the set picture1.picture line

@anv
i already stored the filename & its path on my db, i just need to output it on the picture control
0
 
LVL 10

Expert Comment

by:anv
ID: 12141552
check the field name ur giving in the code with the database

use this instead rs!tblAdv_FileName  where tblAdv_FileName is the field name as given in the database
0
 
LVL 8

Accepted Solution

by:
mladenovicz earned 480 total points
ID: 12141557
Set Picture1.Picture = LoadPicture(rs.Fields("tblAdv_FileName").Value)
0
 

Author Comment

by:justin_316_sr
ID: 12141603
@mladenovicz

arrgghh! so thats what i forgot! hahaha, this programming just takes soooo much from me... maybe i'll just rest for a while and maintain my "sanity" hahaha

tnx, points awarded
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now