Changing connectionstring via Classic ASP

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for COM/ActiveX (v7)  /  Changing connectionstring via Classic ASP

DynamicPDF CoreSuite for COM/ActiveX (v7) Forum

Hi, I was wondering if anyone can point out how to change the ConnectionString within the .DPLX at runtime. I am using Classic ASP.

Thanks in advance.
Posted by a ceTe Software moderator
Hello,

Yes, you can dynamically set the desired connection string and query using version 7 DynamicPDF ReportWriter for COM/ActiveX product. You will need to dynamically access the Query using its ID. Then you can use OpeningRecordSet event of the Query object to change the connection string and the query. Please refer to the documentation on
event driven queries here. Also below is the code sample.

<!-- METADATA TYPE="typelib" UUID="{DF9225FE-94A4-490d-8CAD-E8366CE621D3}"-->
<%
     Dim MyDocument
     Set MyDocument = Server.CreateObject( "DynamicPDF.Document" )
     Dim MyDocumentLayout
     Set MyDocumentLayout = Server.CreateObject( "DynamicPDF.DocumentLayout")
     MyDocumentLayout.LoadDplx ("D:\Temp\Document1.dplx")
     Dim Qry
     Set Qry = MyDocumentLayout.GetQueryById("Query1")
     Dim OpenRecSet
     Set OpenRecSet = GetRef("Query_OpeningRecordSet")
     Qry.OpeningRecordSet OpenRecSet
     Set MyDocument = MyDocumentLayout.Run
     MyDocument.DrawToWeb

  Private Function Query_OpeningRecordSet(e)
     Dim MyRecordSet
     Set MyRecordSet = Server.CreateObject("ADODB.Recordset")
     Dim SqlConn
     Set SqlConn  =  Server.CreateObject("ADODB.Connection")
     Dim SqlCmd
     Set SqlCmd  = Server.CreateObject("ADODB.Command")
     SqlConn.ConnectionString ="Correct and valid valid connection string"
     SqlConn.Open                                                                                                   
     SqlCmd.ActiveConnection = SqlConn
     SqlCmd.CommandText = "Select * from Products"
     MyRecordSet.Open SqlCmd ,  ,  adOpenStatic
     e.AddRecordSet(MyRecordSet)    
  End Function
%>

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 8:22 AM.