ปัจจุบันใช้ 2008 Server 32 Bit + IIS7 + Asp Classic แล้วเรียก Report ผ่าน Web ครับ
โดยใช้คำสั่ง
Code (ASP)
<%
id = request("id")
f = request("f")
db = "Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;SourceDB="
db = db & server.mappath("history\new\pay_hist.dbc")
db = db & ";Exclusive=No;NULL=NO;DELETED=YES;"
set conn=server.createobject("adodb.connection")
conn.open db
sql = "select * from pay_hist where citizen_id = '310020008085'"
reportname = "pay_bill.rpt"
%>
<!-- #include file="AlwaysRequiredSteps.asp" -->
<%
Set oADOConnection = Server.CreateObject("ADODB.Connection")
oADOConnection.Open conn
Set oADORecordset = Server.CreateObject("ADODB.Recordset")
Set oADORecordset = oADOConnection.Execute(sql)
Set oRptTable = session("oRpt").Database.Tables.Item(1)
oRptTable.SetDataSource oADORecordset, 3
%>
<!-- #include file="MoreRequiredSteps.asp" -->
<!-- #include file="SmartViewerActiveX.asp" -->
---------------------------------------
AlwaysRequiredSteps.asp
---------------------------------------
<%
If Not IsObject (session("oApp")) Then
Set session("oApp") = Server.CreateObject("CrystalRuntime.Application.10")
End If
Path = Request.ServerVariables("PATH_TRANSLATED")
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend
If IsObject(session("oRpt")) then
Set session("oRpt") = nothing
End if
On error resume next
Set session("oRpt") = session("oApp").OpenReport(path & reportname, 1)
If Err.Number <> 0 Then
Response.Write "Error Occurred creating Report Object: " & Err.Description
Set Session("oRpt") = nothing
Set Session("oApp") = nothing
Session.Abandon
Response.End
End If
%>
---------------------------------------------------------
MoreRequiredSteps.asp
---------------------------------------------------------
<%
session("oRpt").ReadRecords
If Err.Number <> 0 Then
Response.Write "Error Occurred Reading Records: " & Err.Description
Set Session("oRpt") = nothing
Set Session("oApp") = nothing
Session.Abandon
Response.End
Else
If IsObject(session("oPageEngine")) Then
set session("oPageEngine") = nothing
End If
set session("oPageEngine") = session("oRpt").PageEngine
End If
%>
---------------------------------------------------------
SmartViewerActiveX.asp
---------------------------------------------------------
<%
%>
<HTML>
<HEAD>
</HEAD>
<BODY BGCOLOR=C6C6C6 ONUNLOAD="CallDestroy();" leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0>
<OBJECT ID="CRViewer"
CLASSID="CLSID:A1B8A30B-8AAA-4a3e-8869-1DA509E8A011"
WIDTH=100% HEIGHT=99%
CODEBASE="/crystalreportviewers10/ActiveXControls/ActiveXViewer.cab#Version=10,0,0,280" VIEWASTEXT>
<PARAM NAME="EnableRefreshButton" VALUE=1>
<PARAM NAME="EnableGroupTree" VALUE=1>
<PARAM NAME="DisplayGroupTree" VALUE=0>
<PARAM NAME="EnablePrintButton" VALUE=1>
<PARAM NAME="EnableExportButton" VALUE=0>
<PARAM NAME="EnableDrillDown" VALUE=1>
<PARAM NAME="EnableSearchControl" VALUE=1>
<PARAM NAME="EnableAnimationControl" VALUE=1>
<PARAM NAME="EnableZoomControl" VALUE=1>
</OBJECT>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Window_Onload
On Error Resume Next
Dim webBroker
Set webBroker = CreateObject("CrystalReports10.WebReportBroker.1")
if ScriptEngineMajorVersion < 2 then
window.alert "IE 3.02 users on NT4 need to get the latest version of VBScript or install IE 4.01 SP1. IE 3.02 users on Win95 need DCOM95 and latest version of VBScript, or install IE 4.01 SP1. These files are available at Microsoft's web site."
else
Dim webSource
Set webSource = CreateObject("CrystalReports10.WebReportSource.1")
webSource.ReportSource = webBroker
webSource.URL = "RDCrptserver10.asp"
webSource.PromptOnRefresh = True
CRViewer.ReportSource = webSource
end if
CRViewer.ViewReport
End Sub
-->
</SCRIPT>
<script language="javascript">
function CallDestroy()
{
window.open("Cleanup.asp");
}
</script>
</BODY>
</HTML>
---------------------------------------------------------------------------------------
แล้วติดปัญหาด้านล่าง
Error Occurred Reading Records: Failed to load database information. Details: The database DLL 'crdb_fielddef.dll' could not be loaded.
---------------------------------------------------------------------------------------