this is my code , it should save a pdf file from sql server to a folder but nothing happened can anyone help please ??

Set rs = New ADODB.Recordset
rs.Open "select * from PDFStore where filename='" & co_name.Text & "'", db, adOpenKeyset, adLockBatchOptimistic
If Not rs.EOF Then

Set pdffile = New ADODB.Stream
pdffile.Type = adTypeBinary
If IsNull(rs.Fields("Contents")) = False Then
pdffile.Write rs.Fields("Contents").Value
Dim pdfname As String
pdfname = co_name.Text
pdffile.SaveToFile "" & App.Path & "\report\" & pdfname & ".pdf", adSaveCreateOverWrite
Set pdffile = Nothing
MsgBox "NO"
Set rs = Nothing

End If

End If

The first thing I'd do is set a breakpoint at the first line you posted, and step through the code as it runs. Have you tried this? It should give us a better idea of what's actually happening.

what i do i saved a pdf file in sql server 2008 and now i need to retrieve the file from the sql and save it to folder in project path to open it , i dont know how i can retrive by open directly the file or save it in a folder ,

What does "nothing happened" mean? I assume you at least ran the code you posted. It looks like it should retrieve PDF content and save it to a file, but it doesn't open the file for viewing. Was the file created?

This article has been dead for over six months. Start a new discussion instead.