Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Crystal Report ASP Stream to PDF "Failed to retrieve data from the database"

Posted on 2006-06-22
4
Medium Priority
?
3,169 Views
Last Modified: 2012-06-27
I have a Crystal Report (version XI) that I launch from a VB.NET Web App.  It has worked for months.  Then, yesterday, it suddently stopped working.  I redeployed my files to the web server, thinking maybe something got corrupted out there, but it didn't help.  The code I am using to run the Crystal Report (that worked fine for a long time) is as follows:

    Private Sub ShowReportEmbedded()
        Dim oRpt As sl_List4
        oRpt = New sl_List4
        oRpt.SetDatabaseLogon(strUser, strPassword)

        sSQL.Length = 0
        sSQL.Append("    {SL_LIST.ListSite} = '" & Request.Item("slSite").ToString & "' ")
        sSQL.Append("AND {SL_LIST.ListRev} = '" & Request.Item("slRev").ToString & "' ")
        sSQL.Append("AND date({SL_LIST.ShipListDate}) = date('" & CDate(Left(Request.Item("slDate").ToString, 2) & "-" & Mid(Request.Item("slDate").ToString, 3, 3) & "-" & Right(Request.Item("slDate").ToString, 2)) & "') ")

        oRpt.RecordSelectionFormula = sSQL.ToString

        Dim st As System.IO.MemoryStream
        st = oRpt.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat)

        Response.ClearContent()
        Response.ClearHeaders()
        Response.ContentType = "application/PDF"
        Response.AddHeader("Content-Disposition", "inline; filename=list.pdf")
        Response.BinaryWrite(st.ToArray)
        Response.Flush()
        Response.Close()
    End Sub

The error says:  Failed to retrieve data from the database.

Any ideas?
0
Comment
Question by:AptDev
  • 2
4 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 1000 total points
ID: 16965085
What has changed on the machine?

mlmcc
0
 
LVL 42

Assisted Solution

by:frodoman
frodoman earned 1000 total points
ID: 16969199
What type of database are you connecting to?  Have you verified that you can still connect from this machine to the database?

It could be many, many things, but my first suspicion would be that either a patch has been applied which has changed the security settings or a firewall has been changed.  In either case, the report cannot reach the database any longer.  Try executing the same report standalone (if you can) in the same location and see if it works that way.

frodoman
0
 

Author Comment

by:AptDev
ID: 16993885
After reading your question "What changed" it suddenlty hit me that I had added a field to that table.  A little more exploration showed me the line that was causing the problem was the line about dates.   I just worked with it until it worked.  Although I have no idea how the table changed to require the new code, I simply changed from a date to a datetime and it worked flawlessly.  Thank you both for your comments that lead me in that direction.  Here is the only change I made to the above code to get it to work:

sSQL.Append("AND {SL_LIST.ShipListDate} = datetime('" & CDate(Left(Request.Item("slDate").ToString, 2) & "-" & Mid(Request.Item("slDate").ToString, 3, 3) & "-" & Right(Request.Item("slDate").ToString, 2)) & "') ")

Thank you both for your endless help on this forum!
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 16998278
Anytime you change the table you need to VERIFY THE DATABASE in Crystal.  Under the DATABASE menu

Glad i could help

mlmcc
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question