在数据库中存储图像

问题描述:

如何将图像添加到数据库,以便在准备Crystal Report时可以在vb中使用这些图像?
有什么程序吗?

请准确地指导我.

谢谢.

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.

1.不要将整个图像保存在数据库中.这不是一个好方法.
2.将图像保存在项目/网站的任何文件夹中,并将其路径保存到数据库.

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.

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.要在水晶报表中显示图像,请参考1 [参考-2 [



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

Hope it helps.


尝试
如何在数据库中存储图像(或其他文件) [
Try
How can I store images (or other files) in a database[^] to learn step by step process to save Image in Database.


也尝试此链接

点击 [
try this link also

Click[^]