Hi, I am an I.T student and currently working with my system. Please teach me how can i save the image link im my database using vb.net, i am done with the browsing, uploading and removing of image except saving.. please help i would be really ideas only on how to work with it. Thank You!

Recommended Answers

All 3 Replies

If it's a link then all you have to do is write it to the database as a string ("C:\folder\image.jpg"). So you add a field called "imgLocation" or something and then write the link to that field.

If this doesn't help then reply with more information such as an exemplar image link that you want to save etc

Public Class Form1
    Dim con As New OleDb.OleDbConnection
    Dim daM As OleDb.OleDbDataAdapter
    Dim dsM As New DataSet
    Dim recCount, recNo As Integer
    Dim dp As String
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.Title = "Get Image"
        OpenFileDialog1.ShowDialog()
    End Sub

    Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
        TextBox1.Text = OpenFileDialog1.FileName
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If (TextBox1.Text.Trim() <> "") Then
            PictureBox1.Image = Image.FromFile(TextBox1.Text)
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        PictureBox1.Image = Nothing
    End Sub


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        con.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Jelle May\Documents\Database6.mdb"

        dp = "Select * from Table1"
        con.Open()
        daM = New OleDb.OleDbDataAdapter(dp, con)
        daM.Fill(dsM, "Table1")
        con.Close()

    End Sub
End Class

i set my database datatype as OLE Object for image is that alright? if i click the save button the link should be saved at my database.. i dont know how to save it ^^.. tnx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.