Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Insert an attachment into a SQL database

Posted on 2011-10-11
2
Medium Priority
?
236 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:Murray Brown
2 Comments
 
LVL 7

Accepted Solution

by:
mozcullu earned 2000 total points
ID: 36948477
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
 

Author Closing Comment

by:Murray Brown
ID: 36986231
Thanks very much
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question