Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
amitkumarmadhukar
Starting Member
45 Posts |
Posted - 2004-07-23 : 05:26:22
|
Hello, Every OneI m developing such a application program in Visual Basic (Actually i want to add this as a facility in my existing application)Where i can ,Either able to SCAN any photos( of Employee/Customer) and save the photo at SQL Server, with some primary key.and in otherhand i use to display that photo on VB Forms and i give an employee ID for searchingOr,able to Read Photos( of Employee/Customer) from Disks and save the photo at SQL Server, with some primary key.and in otherhand i use to display that photo on VB Forms and i give an employee ID for searchingPlease give the Example Code.the method and any other scope towards solutionamit kumar madhukar |
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2004-07-25 : 19:25:01
|
Amit, It's generally accepted in the SQL community that you don't save images or other binary data in the database. All you need to do is drop the files on a network drive then store the path in the database. If you must store the files in the db itself, have a google around for some code. There's loads of it out there to do what you're doing.Tim |
|
|
sodakotahusker
Starting Member
2 Posts |
Posted - 2004-07-25 : 20:00:28
|
Timmy is right. Store the path/file name to your picture in SQL with some kind of key to find it. Let's use a simple example. You have a customer table with name, address, birthdate etc in it. Include a field call photo. Store the file name such as d:\customers\photos\11.jpgThen in vb draw an image on the formWhen loading a customer record - use the code image1.picture = loadpicture("d:\customers\photos\11.jpg")of course you won't hard code the picture name so you would probably use the recordset variable itself.image1.picture = loadpicture(adoRS!photo)and if a photo field was null/empty you could have a canned picture which says photo not available or something - which you would load instead. |
|
|
samtoffa
Yak Posting Veteran
60 Posts |
Posted - 2004-07-26 : 16:15:24
|
I would agree that as a general rule of thumb it's best to keep images as files in directories not on the DB but there are occasionally reasons why people like to do the latter. This is why the Northwind DB that ships with SQL Server has photographs embedded in the Employee table. Such reasons include access control by SQL Server user accounts etc and the fact that you can copy fields to a table on a different machine without having to worry about resolving to the correct file path.Amit, my advice for someone who wants to learn how to use this is to set up a connection to the Northwind database (e.g. using ODBC) then use the Employee table as the recordsource for your VB form. Practice with this and I'm sure you'll learn how to do the things that you need to do.Sam |
|
|
|
|
|