Solved

RUSH >>> Loading picture

Posted on 2004-09-24
8
210 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
Technology Partners: 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 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
 

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

Independent Software Vendors: 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!

Question has a verified solution.

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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

740 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