Ipinapakita ang mga post na may etiketa na VB 6. Ipakita ang lahat ng mga post
Ipinapakita ang mga post na may etiketa na VB 6. Ipakita ang lahat ng mga post

Martes, Pebrero 14, 2012

How to save an image in ms access database using vb.net?

You can store any image format in the database because you are storing it using Byte data.

Yes, you can click on an image in a DataGridView and have it display larger.  This is something I used a few weeks ago to do just that:


Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
        If e.ColumnIndex <> 1 Then Exit Sub
        fn = DataGridView1.Item(1, e.RowIndex).Value.ToString
        Form2.ShowDialog()
    End Sub

In this example, if the click occurs in any column other than the second column (index 1) then don't do anything (Exit Sub).  If the click occurs in the second column, I retrieve the filename (including its path which I also show in the DataGridView, and pass that in a global variable to a second form.  The second form has only 1 PictureBox with its SizeMode set to  Zoom.  Set the PictureBox.Image property to Image.FromFile using the path and filename in the global variable.

One thing you should know about storing images in a database is that the database will become VERY large depending on the size of each image and the number of images you store.


http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/09c4e2f4-540f-409b-a503-db941e81b965 

How to save and image to msaccess using vb 6 code?

How to save and image to msaccess using vb 6 code?


(a) Create a database file (MS ACCESS) having a DATAFIELD name (say image1). 

(b) Place a DATA component (say DATA1) in main vb form. Select this DATA1 component and then select database name property and browse for above MS ACCESS file and select to open the file. This will save the file path. 

(c) Place a text box (say text8) in vb form and set it's visible property to false. Also, select DATASOURCE property 
(say DATA1) and DATAFIELD(say image1). 

(d) Place a common dialog box in your form (say commondialog1). 

(e) Place an image box component in your form (say image1) 

(f) Now, this simple code will load and save any image present in your hard disk: 

Private Sub Command4_Click() 
Form1.CommonDialog1.Filter = "JPG Files|*.jpg|BMP Images|*.bmp|GIF Images|*.gif" 
On Error Resume Next 
Form1.CommonDialog1.ShowOpen 
On Error Resume Next 
Form1.CommonDialog1.CancelError = True 
Form1.Text8.Text = Form1.CommonDialog1.FileName 
a = Form1.Text8.Text 
Form1.Image1.Picture = LoadPicture(a) 

End Sub 



How to Read/Write Image files from/to Access DB using ADO