Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help in reference to VB -Access 2000 project 1

Status
Not open for further replies.

Maneet

Programmer
Jan 3, 2006
2
0
0
US
I am working on a project with VB 6.0 as front end and Microsoft Access 2000 as backend , i am facing 2 problems :
I want to use a bound control , which can bind to a field in backend which has OLE Object data type , so that when i navigate records of that table , it shows me pictures stored in the records , in this control . also this control should be able to import and export pictures by specifying the path through common dialog box . Please tell me which control can be used for this and how ? Please tell me specifically for ACCESS 2000.
when i am using data environment and making commands and using it in binding controls in forms , then in case of text boxes which are bound to fields of data type DATE/TIME i am facing a problem . when i enter in the text box and fill some invalid date , then it doesn't let me come out of this control , even if i delete the value , or this control is blank or i specifically through coding assign it null , it doesn't let me save the record , i have to compulsorily fill a a valid value if i enter such control . Please tell me how to solve this problem .
Maneet
maneet9@yahoo.com
 
Hi

I can show you a not so glamorous way of achieving that.

My database

I have a field (OLE Object) & a field (Long)
The OLE Object is my picture & the Long field is for arguments sake called Filelength.
I store the binary length of the picture inside this field
for reasons that may become apparent as this example unfolds

Database Access Technology

I use ADO 2.5 (ActiveX Data Objects) SP1

Data Store Retrieval

I use the .AppendChunk and .GetChunk methods of the RecordSet.Fields.Field object

The pseudocode...
Retrieve picture from database
[ul][li]Open the database[/li]
[li]Get the user's temp folder (normally C:\Windows\Temp\)
& generate a temp file name (I use API but you don't have to)[/li]
[li]Retrieve the picture and store it within the file (Using GetChunk)[/li]
[li]Assign that file to a picture box using .LoadPicture[/li]
[li]Delete the file (temp file)[/li][/ul]
Save picture to database
[ul][li]Display Common dialog for choosing picture[/li]
[li]Load picture into picture box[/li]
[li]When the user opts to save to database, open the file name the user chose in Binary mode (I use CommonDialog.FileName property to get the file name)[/li]
[li]Read the contents (of the file )into a byte array[/li]
[li]Open the database/connection (if not open)[/li]
[li]Save byte array to ole object field using Appendchunk[/li]
[li]Save the file length to the FileLength field[/li]
[/ul]

If you'd like to go that route then I'll publish the source code. The pseudocode is (i hope) to provide you with some sort of idea as to the process involved in my method of achieving this

The code that I have works (not only on Access 2000 but on versions 95 & 97 as well.)

Let me know if you want the source

Craig
 
caf,
That's an interesting procedure.
Would you mind posting the source code?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top