Solved

Save PDF to SQL VB6

Posted on 2014-12-03
4
708 Views
Last Modified: 2015-01-02
I am working on a project and know how to save pdf to sql using c# but cannot figure it out in ADO VB6. I wan tot be able to delcare a location of the pdf and have it save that file to sql as binary.


Thanks ahead
0
Comment
Question by:desiredforsome
4 Comments
 

Accepted Solution

by:
desiredforsome earned 0 total points
Comment Utility
I am closing this case but would like to add my solution for anyone that is likley to find this question online.

Dim pdfpath, pdfpath1 As String
Dim sql As String

Public pdffile As ADODB.Stream
Dim database As New ADODB.Connection
Dim rs As ADODB.Recordset





Private Sub Command1_Click()
database.ConnectionString = "Provider=sqloledb; Data Source=192.168.2.121\EMMSDE;Initial Catalog=outlookreport; User Id=jsmith; Password=s5993153492;"
database.Open
sql = "SELECT * FROM PDFTABLE"
Set rs = New ADODB.Recordset

rs.Open " select * from pdftable", database, adOpenKeyset, adLockOptimistic
rs.AddNew

Set pdffile = New ADODB.Stream
pdffile.Type = adTypeBinary
pdffile.Open
pdffile.LoadFromFile "C:\test.pdf"
rs.Fields("pdf") = pdffile.Read
pdffile.Close
Set pdffile = Nothing
rs.Update
Set rs = Nothing
MsgBox "Saved"
database.Close






End Sub

Open in new window

0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now