VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Insert picture using VB into SQL Server for Datatype Image.

by Noorha Merchant / Naresh Gupta (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sat 28th October 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Insert picture using VB into SQL Server for Datatype Image.

Rate Insert picture using VB into SQL Server for Datatype Image.



On Error GoTo ErrHandler

    Dim bytData() As Byte
    Dim sFileName As String
    
    sFileName = "Path and Name of your Picture for insert"
    
    Open sFileName For Binary As #1
    If FileLen(sFileName) = 0 Then
        MsgBox "Your Message"
        Close #1
        Exit Sub
    Else
        ReDim bytData(FileLen(sFileName))
        Get #1, , bytData
        Close #1
        With rsPic 'Assuming u have open your recordset
            .AddNew
            .Fields("EmployeePhoto").AppendChunk bytData 
            'Assuming EmployeePhoto is Field in Database with datatype as image
            'Your Other Related Fields here
            .Update
        End With
    End If
    Exit Sub
    
ErrHandler:
    MsgBox Str(Err.Number) + " : " + Err.Description, vbInformation
    Err.Clear
End Sub

Download this snippet    Add to My Saved Code

Insert picture using VB into SQL Server for Datatype Image. Comments

No comments have been posted about Insert picture using VB into SQL Server for Datatype Image.. Why not be the first to post a comment about Insert picture using VB into SQL Server for Datatype Image..

Post your comment

Subject:
Message:
0/1000 characters