Click here to Skip to main content
15,891,993 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How we can add images to databases so that we can use the images in vb while preparing crystal report?
Is there any procedure for that?

Please guide me exactly.

Thanks.
Posted
Updated 3-May-11 21:35pm
v4
Comments
Sergey Alexandrovich Kryukov 4-May-11 2:43am    
I modified the title because "To install" seems to be inapplicable; could be just wrong English usage. Is that what you mean to ask?
--SA
Dalek Dave 4-May-11 3:35am    
Edited for Grammar, Syntax and Readability.

1. Don't save whole image in database. It is not a good approach.
2. Save your image at any folder of your project/website and save its path to the database.

VB
If file.PostedFile.ContentLength > 0 Then ''// Upload file if length > 0
         Dim strExt As String
         strExt = IO.Path.GetExtension(file.PostedFile.FileName) '// Get Extension
         If imageName = "" Then '// change name if not specify
             strImgName = Trim(Now.Year.ToString & Now.Hour.ToString & Now.Minute.ToString & Now.Millisecond.ToString & imageName) '// So that image can not be duplicate
             strImgName = strImgName & strExt
         Else
             strImgName = imageName & strExt '// take given name
         End If
         If Not (checkExt(file.PostedFile.FileName, ".jpg") Or checkExt(file.PostedFile.FileName, ".gif") Or checkExt(file.PostedFile.FileName, ".png")) Then
             lblMsg.Text = "Upload only .gif,.png or .jpg file format."
             lblMsg.Visible = True
             Return ""
         End If
         If strImagePath <> "" Then
             If System.IO.Directory.Exists(strImagePath) Then file.PostedFile.SaveAs(strImagePath & strImgName)
         End If
     Else
         strImgName = "" '// file uplaod has no image uploaded
     End If


3. For displaying image in the crystal report, Reference-1[^] and Reference - 2[^]

Hope it helps.
 
Share this answer
 
Comments
Dalek Dave 4-May-11 3:35am    
Good Call.
That's Aragon 4-May-11 3:47am    
Thank you DD. :)
Tarun.K.S 4-May-11 4:38am    
Good answer. 5+
That's Aragon 4-May-11 5:41am    
Thanks Tarun
Try
How can I store images (or other files) in a database[^] to learn step by step process to save Image in Database.
 
Share this answer
 
Comments
Dalek Dave 4-May-11 3:36am    
Good Link.
RaviRanjanKr 4-May-11 5:51am    
Thanks DD.
Tarun.K.S 4-May-11 4:39am    
Good link Ravi! +5
RaviRanjanKr 4-May-11 5:51am    
Thanks Tarun.
try this link also

Click[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900