Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > CR doesn't work with SQL Server in ASP

Reply
Thread Tools

CR doesn't work with SQL Server in ASP

 
 
Jane
Guest
Posts: n/a
 
      07-31-2003
Hello,

I get the error Error Occured Reading Records: Server has
not yet been opened. when I am trying to view a report
using the asp pages for crystal reports. It works fine
for access files. Can someone help me on it?

Thanks in advance!

Jane
 
Reply With Quote
 
 
 
 
John Beschler
Guest
Posts: n/a
 
      07-31-2003
Jane,

Post your code and perhaps someone will be able to help.

John


>-----Original Message-----
>Hello,
>
>I get the error Error Occured Reading Records: Server has
>not yet been opened. when I am trying to view a report
>using the asp pages for crystal reports. It works fine
>for access files. Can someone help me on it?
>
>Thanks in advance!
>
>Jane
>.
>

 
Reply With Quote
 
 
 
 
Jane
Guest
Posts: n/a
 
      08-01-2003
Here is the code. I realize there is nowhere I can put the
login information to connect to SQL Server.

<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio
6.0">
<script language="javascript">
function CallDestroy()
{
window.open("Cleanup.asp");
}

function reminder()
{
window.alert("Please close down the Report window
as soon as you are done. Since there are only 5 users can
use it at same time!")
}
</script>
</HEAD>
<BODY ONUNLOAD="CallDestroy();" onLoad="reminder()">

<% Dim sSQL, sWhere
sSQL=Request.Form("sql")

'-- get report name
reportname = "Report1.rpt"

If Not IsObject (session("oApp"))
Then
Set session("oApp") = Server.CreateObject
("CrystalRuntime.Application")
End
If
Call session("oApp").SetMorePrintEngineErrorMessages(0)
Call session("oApp").SetMatchLogonInfo(1)

Path = Request.ServerVariables
("PATH_TRANSLATED")
While (Right(Path, 1) <> "\" And Len(Path) <>
0)
iLen = Len(Path) -
1
Path = Left(Path,
iLen)
Wend
'Response.Write (Path) & "<br>"

If IsObject(session("oRpt")) then
Set session("oRpt") = nothing
End if

On error resume next
'-- get report file path
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

'-- disable the Error reporting
session("oRpt").MorePrintEngineErrorMessages = False
session("oRpt").EnableParameterPrompting = False

session("oRpt").DiscardSavedData

'-- build the new SQL Query String for the report
NewQueryString="Select * From vewODRpt1220"

Response.Write (NewQueryString) & "<br>"
session("oRpt").SQLQueryString = CStr(NewQueryString)



On Error Resume Next
session("oRpt").ReadRecords
If Err.Number <> 0
Then
Response.Write "Error Occurred Reading Records: " &
Err.number & ", " & 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
%>

<OBJECT ID="CRViewer1"
CLASSID="CLSID:C4847596-972C-11D0-9567-
00A0C9273C2A"
WIDTH=100%
HEIGHT=100%

codebase="/viewer/activeXViewer/activexviewer.cab#Version=8
,5,0,217">
<param name="EnableGroupTree" value=1>
<param name="DisplayGroupTree" value=1>
<param name="EnableRefreshButton" value=1>
<param name="EnablePrintButton" value=1>
<param name="EnableExportButton" value=1>
<param name="EnableSearchControl" value=1>
<param name="EnableDrillDown" value=1>
<param name="EnableAnimationControl" value=1>
<param name="EnableZoomControl" value=1>
</OBJECT>

<SCRIPT LANGUAGE="VBScript">
Call Page_Initialize

Sub Page_Initialize
On Error Resume Next
Dim WebBroker1
Set WebBroker1 = CreateObject
("WebReportBroker.WebReportBroker")
Call GetURL(URL)
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."
CRViewer1.ReportName = URL
+ "rptserver.asp"
else
Dim WebSource1
Set WebSource1 = CreateObject
("WebReportSource.WebReportSource")
WebSource1.ReportSource = WebBroker1
WebSource1.URL = URL + "rptserver.asp"
WebSource1.PromptOnRefresh = true
CRViewer1.ReportSource = WebSource1
Response.Write (WebSource1) & "b<br>"
end if
CRViewer1.ViewReport
End Sub

Sub GetURL(ByRef URL)
HREF = Location.Href
URL= ""
nPos = InStr(HREF, "/")
While (nPos > 0)
URL = URL & Left( HREF, nPos )
HREF = Mid(HREF, nPos + 1)
nPos = InStr(HREF, "/")
Wend
End Sub
</SCRIPT>
</BODY>
</HTML>


>-----Original Message-----
>Jane,
>
>Post your code and perhaps someone will be able to help.
>
>John
>
>
>>-----Original Message-----
>>Hello,
>>
>>I get the error Error Occured Reading Records: Server

has
>>not yet been opened. when I am trying to view a report
>>using the asp pages for crystal reports. It works fine
>>for access files. Can someone help me on it?
>>
>>Thanks in advance!
>>
>>Jane
>>.
>>

>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help. Getting a An error has occurred while establishing a connectionto the server. When connecting to SQL Server 2005, this failure may be causedby the fact that under the default settings SQL Server does not allow remote aboutjav.com@gmail.com ASP .Net 0 05-03-2008 12:43 PM
Do the Self-Paced Training Kits: Microsoft SQL Server 2000 include Eval copy of SQL Server? Brian Whiting Microsoft Certification 2 12-29-2005 04:24 AM
sql server express vs sql server 2000 code Daves ASP .Net 1 06-13-2005 12:24 PM
How to read an SQL Server into a ASP page and then change, add, delete and write it back to SQL Server Belinda ASP General 4 06-11-2004 12:16 PM
Can't connect to SQL Server, using Windows Authentication users of SQL server? help =?Utf-8?B?UmV6YQ==?= ASP .Net 3 06-07-2004 06:42 PM



Advertisments