Solved

RUSH >>> Loading picture

Posted on 2004-09-24
8
208 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 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…

778 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