Solved

Save PDF to SQL VB6

Posted on 2014-12-03
4
769 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA Excel: Copy Data from one workbook to another v6 csv extension 15 77
Excel Vlookup to move data back to source. 4 84
MsgBox 2 47
How to debug this code 7 56
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

895 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

15 Experts available now in Live!

Get 1:1 Help Now