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 

Walang komento:

Mag-post ng isang Komento