ASP/ADO/FDF

 

Access Data Objects (ADO) 2.5 or Later

Access Data Objects are an object that links the server scripts to the database.

Within the active server script you must declare the object, set the parameters, and then close the object as soon as possible.

This coding example illustrates how to import data to FDF/PDF from a database

<%@ Language=VBSCRIPT %>

<% Option Explicit %>

<%

On error resume next

Dim RS ‘ Declare Recordset

Dim ConnStr ‘ Declare Connection String

Dim RecordCounter

Dim FDFAcx, FDFin

Set RS = Server.CreateObject(“ADODB.Recordset”)

ConnStr = “Provider=Microsoft.Jet.OLEDB.4.0; Data Source=” & _

          Server.MapPath(“/Databases/My_Database.mdb”)

 

‘ Open Updatable Recordset Syntax is as follows

‘ RS.Open SQL/Table, Connection, 3=OpenKeyset, 3=LockOptimistic

RS.Open “Select * From Table_One Where Unique_ID = 2”, ConnStr, 3,3

 

‘ Check if a record is found

RecordCounter = RS.RecordCount

If RecordCounter < 1 then

          Response.Write “No Records Found”

          Response.End

End if

‘ Call Subroutine to perform Data Population

Perform_Query

 

Sub Perform_Query()

Response.ContentType = "application/vnd.fdf"

Set FdfAcx = Server.CreateObject("FdfApp.FdfApp")

Set FDFout = FdfAcx.FDFCreate

FDFout.FDFSetFile = Server.MapPath(“PDFs/My_PDF.pdf”)

 

‘ 1. Open FDF From File Or Open from Buffer (Uncomment One of them)

‘ Set FDFin=FdfAcx.FDFOpenFromFile(Server.MapPath(“/PDF/my_file.pdf”))

‘ Set FDFin = FdfAcx.FDFOpenFromBuf (Request.BinaryRead(Request.TotalBytes))

 

‘ If the field type is a string then add a empty string to the end to not throw an error

FDFout.FDFSetValue “Fieldname_One”, RS(“Fieldname_One") & “”

 

‘ If the field type is numeric then add zero to not throw an error

FDFout.FDFSetValue “Fieldname_Two”, RS(“Fieldname_Two”) + 0

FDFout.FDFSetStatus “Page Updated with new Values”

Response.BinaryWrite FDFout.FDFSaveToBuf

FdfAcx.Close

Respone.End

End Sub

%>

 

 

Home
PDF Programming
ASP Server Setup
ASP Programming
Digital Signatures
FDF Programming
ASP.Net Server Setup
ASP.NET
Problems and Solutions
VB6 Programming
FDF Exporting
Importing FDF
ASP/ADO/FDF

 

Copyright © 2003, 1991 - 2002