Dream is not what you see in sleep. It is something that does not let you sleep. -Abdul Kalam

Name    : Muthukumar Nadar
email   : nadarmuthukumar@yahoo.co.in
Mobile  : 9833240124
City    : Mumbai
State   : Maharashtra
Country : India

So guys, as if now this is all about my contact details if anybody have any doubt on anything are most welcome to contact me, and i assure you that i will try my best to Solve your problem.

And Student looking for IT Projects can also Contact me.

To Download Source Code Click Here > Save image in MySettings.rar

  1. Open Visual Studio and Click on New Project window from template.
  2. Place Four buttons and a Picture box.
  3. Set Name Properties of :
    1. Button1 = "btnBrowse"
    2. Button2 = "btnSave"
    3. Button3 = "btnDelete"
    4. Button4 = "btnExit"
    5. Picturebox1 = "pctImage" 
    6. OpenFileDialog1 = "ofdImage"
    7. Form1 = "frmImageSave"
  4.Set Text Properties of :
    1. Button1 = "Browse"
    2. Button2 = "Save"
    3. Button3 = "Delete"
    4. Button4 = "Exit"
    5. Form1 = "Save Image"
  5.Goto Project Menu and Click on SaveImage in MySettings Properties.
  6.From the Left side Select Settings Tab
  7.Now Set the Name as Image.
  8.Select the Type and click on  Browse.
  9. Now a Window will open. In that click on System.Collections. Under that Click on ArrayList. 

10. Select Scope as User.
11. Set Value Field as Empty. I mean don't Enter any value.
12. Right Click on Form and click on View Code.
13. And Paste the following Code.

Imports System.IO

Public Class frmImageSave

    Private Sub frmImageSave_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not My.Settings.Image.Count = 0 Then
            Dim bytImage(My.Settings.Image.Count - 1) As Byte
            For index As Integer = 0 To My.Settings.Image.Count - 1
                bytImage(index) = My.Settings.Image.Item(index)
            Next
            Dim MS As New MemoryStream(bytImage)
            pctImage.Image = Image.FromStream(MS)
        Else
            pctImage.Image = Nothing
        End If
    End Sub

    Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
        With ofdImage
            .InitialDirectory = "C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\"
            .Filter = "JPEGs|*.jpg"
            .FilterIndex = 1
        End With
        If ofdImage.ShowDialog = Windows.Forms.DialogResult.OK Then
            If FormatNumber(FileLen(ofdImage.FileName) / 1024, 0) > 30 Then
                MessageBox.Show("Please Select Image of Size less then 30kbs", "Save Image", MessageBoxButtons.OK, MessageBoxIcon.Information)
                Exit Sub
            End If
            With pctImage
                .Image = Image.FromFile(ofdImage.FileName)
                .SizeMode = PictureBoxSizeMode.StretchImage
            End With
        End If
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Try
            Dim MS As New MemoryStream
            pctImage.Image.Save(MS, Imaging.ImageFormat.Jpeg)
            Dim bytImage() As Byte = MS.GetBuffer
            For index As Integer = 0 To bytImage.Length - 1
                My.Settings.Image.Add(bytImage(index))
            Next
            My.Settings.Save()
            MessageBox.Show("Image Saved Successfully.", "Save Image", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex As Exception
            MessageBox.Show(ex.Message & " btnSave_Click")
        End Try
    End Sub

    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        My.Settings.Image.Clear()
        My.Settings.Save()
        MessageBox.Show("Image Deleted Successfully.", "Save Image", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Application.Exit()
    End Sub

End Class

To Download Source Code Click Here > Save image in MySettings.rar

    Life is Like a piano
    White Keys are Happy moments
    n Black Keys are Sad moments
    But remember both Keys are played
    together to give sweet music
    its Life.

    To Download Source Code Click Here > image to database.rar

    1. Open Visual Studio and Click on New Project Windows from template
    2. Place PictureBox, ListBox, OpenFileDialog, and Four Buttons
    3. Set Name Properties of : 
      1. PictureBox = pctImage, 
      2. ListBox = lstImages, 
      3. Button1 = btnBrowse, 
      4. Button2 = btnSave, 
      5. Button3 = btnDelete, 
      6. Button4 = btnExit
    4. Set Text Properties of : 
      1. Button1 = Browse, 
      2. Button2 = Save, 
      3. Button3 = Delete, 
      4. Button4 = Exit. 
    5. Right Click on the form and Click on View code
    6. And type the following Code.

    Imports System.Data.SQLite
    Imports System.IO
    Imports System.Drawing.Image

    Public Class Form1

        Private Conn As New SQLiteConnection("data Source =" & Application.StartupPath & "\Images.img")
        Private Adpt As SQLiteDataAdapter
        Private strFileName As String

        Private Sub DisplayInList()
            Dim strQry As String = "SELECT imgName FROM MyImage"
            Adpt = New SQLiteDataAdapter(strQry, Conn)
            Dim Dt As New DataTable
            Adpt.Fill(Dt)
            lstImages.DataSource = Nothing
            lstImages.Items.Clear()
            lstImages.DisplayMember = "imgName"
            lstImages.DataSource = Dt
        End Sub

        Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
            With OpenFileDialog1
                .InitialDirectory = "C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\"
                .Filter = "JPEGs|*.jpg"
                .FilterIndex = 1
            End With
            If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                With pctImage
                    .Image = Image.FromFile(OpenFileDialog1.FileName)
                    .SizeMode = PictureBoxSizeMode.StretchImage
                End With
                strFileName = OpenFileDialog1.FileName.ToString
            End If
        End Sub

        Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
            Dim cmd As New SQLiteCommand("DELETE FROM MyImage WHERE imgName = '" & lstImages.Text & "'", Conn)
            cmd.ExecuteNonQuery()
            DisplayInList()
        End Sub

        Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
            Try
                Dim ms As New MemoryStream
                pctImage.Image.Save(ms, Imaging.ImageFormat.Jpeg)
                Dim arrImage() As Byte = ms.GetBuffer
                ms.Close()
                Try
                    Dim strImageName As String = strFileName.Substring(strFileName.LastIndexOf("\") + "1")
                    Dim InsQuery As String = "INSERT INTO MyImage (imgName,imgPict) VALUES(@imgName,@imgPict)"
                    Dim Cmd As New SQLiteCommand(InsQuery, Conn)
                    Cmd.Parameters.Add("@imgName", DbType.String, 50).Value = strImageName
                    Cmd.Parameters.AddWithValue("@imgPict", arrImage)
                    Cmd.ExecuteNonQuery()
                Catch ex As Exception
                    MessageBox.Show("Please select Image to Save")
                End Try
                DisplayInList()
            Catch ex As Exception
                MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End Sub

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Conn.Open()
            If lstImages.Items.Count > 0 Then
                lstImages.SetSelected(0, True)
            End If
            DisplayInList()
        End Sub

        Private Sub lstImages_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstImages.SelectedValueChanged
            Try
                Dim Ds As New DataSet
                Dim strQry As String = "SELECT * FROM MyImage WHERE imgName = '" & lstImages.Text & "'"
                Adpt = New SQLiteDataAdapter(strQry, Conn)
                Adpt.Fill(Ds)
                If Not Ds.Tables(0).Rows.Count = 0 Then
                    Dim arrayImage() As Byte = Ds.Tables(0).Rows(0).Item(1)
                    Dim ms As New MemoryStream(arrayImage)
                    pctImage.Image = Image.FromStream(ms)
                    pctImage.SizeMode = PictureBoxSizeMode.StretchImage
                Else
                    pctImage.Image = Nothing
                End If
              
            Catch ex As Exception
                MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End Sub

        Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
            If Conn.State = ConnectionState.Open Then Conn.Close()
            Application.Exit()
        End Sub

    End Class

    To Download Source Code Click Here > image to database.rar