Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

RUSH >>> Loading picture

Posted on 2004-09-24
8
Medium Priority
?
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Assisted Solution

by:anv
anv earned 80 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
 

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 1920 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 to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

661 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