DON2007

Member
Jun 11, 2007
20
0
0
SQL Database akata dala thiyena Picture akak Crystal Report akaka Load kara ganna Coding Tika kiyanan puluwan da? VB.Net walin:)
 

sanjithkasun91

Well-known member
  • Aug 4, 2009
    3,094
    582
    113
    Colombo
    lokka. oya kiyala tiyanawane mysql database akaka tiyana Image akak Crystel report akata dana widiya dannawanam kiyanna kiyala.
    ??/
    mata oni oya image aka database akata add karapu codding tika...
     

    sasi667

    Member
    Mar 28, 2010
    4
    0
    0
    Malabe
    code for inserting image to a sql data base

    Function SaveImage _
    (ByVal FileName As String) As Integer

    ' Create a FileInfo instance
    ' to retrieve the files information
    Dim fi As New FileInfo(FileName)

    ' Open the Image file for Read
    Dim imgStream As Stream = _
    fi.OpenRead

    ' Create a Byte array the size
    ' of the image file for the Read
    ' methods buffer() byte array
    Dim imgData(imgStream.Length) As Byte
    imgStream.Read(imgData, 0, fi.Length)

    Dim cn As New SqlConnection _
    (ConfigurationSettings.AppSettings("cn"))
    Dim cmd As New SqlCommand("Images_ins", cn)
    cmd.CommandType = CommandType.StoredProcedure

    With cmd.Parameters
    .Add("@FileName", VarChar, 100).Value = _
    fi.Name
    .Add("@FileType", VarChar, 10).Value = +
    fi.Extension
    .Add("@Image", Image).Value = imgData
    .Add("@FileSize", Int, 4).Value = fi.Length
    End With

    cn.Open()
    cmd.ExecuteNonQuery()
    cn.Close()
    cn.Dispose()
    End Function