Insert an attachment into a SQL database

Hi

I am using Imports System.Data.SqlClient with the code below to add new records to my online SQL server database. I want to save attachments to the SQL server database. Is this possible? What sort of code would I use?

Thanks
Sub oUpdate()
        Dim sss As Integer
        'myConnection = New SqlConnection("server=localhost;uid=sa;pwd=;database=pubs")
        myConnection.Open()
        myCommand = New SqlCommand("Update Authors Set city='Oakland' where city='San Jose' ", myConnection)
        sss = myCommand.ExecuteNonQuery()
        MsgBox("Records affected" & sss)
        myConnection.Close()
    End Sub

Open in new window

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
 
Metehan OzculluSQL Service ManagerCommented:
this example can be useful:

CREATE TABLE myTable(Document varbinary(max))
INSERT INTO myTable(Document)
SELECT * FROM OPENROWSET(BULK N'C:\Image1.jpg', SINGLE_BLOB)
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.