Solved

Save PDF to SQL VB6

Posted on 2014-12-03
4
840 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
ID: 40481003
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 46

Expert Comment

by:Martin Liss
ID: 40527526
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

820 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